Package javax.util.jcache

Examples of javax.util.jcache.CacheAttributes


     * sweeps the cache and removes invalid objects, waits for  cleanInterval
     * seconds, then sweeps again etc.
     */
    public void run() {
        CacheImpl cache = CacheImpl.getCache(true);
        CacheAttributes attribs = cache.getAttributes();

        while (active) {
            try {
              Thread.sleep(attribs.getCleanInterval() * 1000);
            } catch (InterruptedException e) {
                //normal
            }
            sweepCache();
        }
View Full Code Here


import javax.util.jcache.CacheException;

public class Bug1097240 {
    public static void main(String[] args) {
        try {
            CacheAttributes ca = CacheAttributes.getDefaultCacheAttributes();
            ca.setDiskPath(System.getProperty("java.io.tmpdir"));
            ca.setDiskCacheSize(1000);
            ca.setMemoryCacheSize(10);
            ca.setMaxObjects(10000);
            ca.setLocal();
            CacheAccessFactory factory = CacheAccessFactory.getInstance();
            javax.util.jcache.Cache cache = factory.getCache();
            cache.close();
            cache.init(ca);
            System.out.println(ca.toString());
            Map cacheMap = factory.getMapAccess();
            long startTime = System.currentTimeMillis();
            System.out.println("writing 25,000 values");
            for (int loop = 0; loop < 25000; loop++) {
                String key = "Key:" + loop;
View Full Code Here

import org.fjank.jcache.CacheSweeper;

public class Bug1037611 extends TestCase {
    public void testResetCache() throws Exception {
        CacheAccessFactory factory = CacheAccessFactory.getInstance();
        CacheAttributes catt = CacheAttributes.getDefaultCacheAttributes();
        catt.setLocal();
        catt.setCleanInterval(1);
        Cache cache = factory.getCache(false);
        //
        cache.init(catt);
        //        CacheSweeper.startSweeper executes
        //        within CacheSweeper.getInstance
View Full Code Here

   * Tests the maxObjects. Sets the maximum number of objects to 5,
   * then tries to insert six.
   * @throws Exception if any faults occurs.
   */
    final public void testSetMaxObjects() throws Exception {
        CacheAttributes ca = CacheAttributes.getDefaultCacheAttributes();
        ca.setMaxObjects(5);
        ca.setLocal();
        CacheAccessFactory factory = CacheAccessFactory.getInstance();
        Cache cache = factory.getCache();
        cache.close();
        cache.init(ca);
        Map map = factory.getMapAccess();
View Full Code Here

                        //ugh.
                        e.printStackTrace();
                    }
                    List addresses = parseAddresses(properties.getProperty("discoveryAddress", "localhost:12345"));
                    //is now parsed, create and populate the CacheAttributes.
                    CacheAttributes attributes = CacheAttributes.getDefaultCacheAttributes();
                    if (!distribute) {
                        attributes.setLocal();
                    }
                    attributes.setDefaultLogFileName(logFileName);
                    attributes.setCleanInterval(cleanInterval);
                    attributes.setDiskCacheSize(diskSize);
                    attributes.setDiskPath(diskPath);
                    attributes.setMaxObjects(maxObjects);
                    attributes.setMemoryCacheSize(maxSize);
                    this.version = version;
                    attributes.setLogger(logger);
                    Iterator iter = addresses.iterator();
                    while (iter.hasNext()) {
                        URL url = (URL) iter.next();
                        attributes.addCacheAddr(InetAddress.getByName(url.getHost()), url.getPort());
                    }
                    init(attributes);
                }
            }
        } catch (IOException e) {
View Full Code Here

    private void initJCacheMap()  {
        try {
            CacheAccessFactory factory = CacheAccessFactory.getInstance();
            Cache cache = factory.getCache(false);
            CacheAttributes attributes = CacheAttributes.getDefaultCacheAttributes();
            attributes.setLocal();
            attributes.setMaxObjects(100000000);
            cache.init(attributes);
            this.jcache= factory.getMapAccess();
        } catch (CacheNotAvailableException e) {
            throw new IllegalStateException(e.getMessage());
        } catch (CacheException e) {
View Full Code Here

import javax.util.jcache.CacheException;

public class DiskBackedHashtable {
    public static void main(String[] args) {
        try {
            CacheAttributes ca = CacheAttributes.getDefaultCacheAttributes();
            ca.setDiskPath(System.getProperty("java.io.tmpdir"));
            ca.setDiskCacheSize(1000);
            ca.setMemoryCacheSize(10);
            ca.setMaxObjects(25000);
            ca.setLocal();
            CacheAccessFactory factory = CacheAccessFactory.getInstance();
            javax.util.jcache.Cache cache = factory.getCache();
            cache.close();
            cache.init(ca);
            System.out.println(ca.toString());
            Map cacheMap = factory.getMapAccess();
            long startTime = System.currentTimeMillis();
            System.out.println("writing 250,000 values");
            Map map = new HashMap();
            try {
View Full Code Here

TOP

Related Classes of javax.util.jcache.CacheAttributes

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.