Package net.sf.cache4j.impl

Examples of net.sf.cache4j.impl.SynchronizedCache


    /**
     * �������� ������ � ������ ��� �� ����.
     */
    public static boolean test_PUT_GET() throws Exception {
        SynchronizedCache cache = new SynchronizedCache();
        CacheConfig cacheConfig = new CacheConfigImpl("cacheId", null, 0, 0, 0, 0, null, "lru", "strong");
        cache.setCacheConfig(cacheConfig);

        Object key = "key";
        Object value = "value";
        cache.put(key, value);

        return cache.get(key)!=null ? true : false;
    }
View Full Code Here


    /**
     * �������� ������. �������� null. ��������� ������ ���� null.
     */
    public static boolean test_PUT_OBJ_PUT_NULL_GET() throws Exception {
        SynchronizedCache cache = new SynchronizedCache();
        CacheConfig cacheConfig = new CacheConfigImpl("cacheId", null, 0, 0, 0, 0, null, "lru", "strong");
        cache.setCacheConfig(cacheConfig);

        Object key = "key";
        Object value = "value";

        cache.put(key, value);
        cache.put(key, null);

        return cache.get(key)==null ? true : false;
    }
View Full Code Here

    /**
     * �������� ������. ������� ������. ��������� ������ ���� null.
     */
    public static boolean test_PUT_REMOVE_GET() throws Exception {
        SynchronizedCache cache = new SynchronizedCache();
        CacheConfig cacheConfig = new CacheConfigImpl("cacheId", null, 0, 0, 0, 0, null, "lru", "strong");
        cache.setCacheConfig(cacheConfig);

        Object key = "key";
        Object value = "value";

        cache.put(key, value);
        cache.remove(key);

        return cache.get(key)==null ? true : false;
    }
View Full Code Here

    /**
     * �������� ������. ������� ���. ��������� ������ ���� null.
     */
    public static boolean test_PUT_CLEAR_GET() throws Exception {
        SynchronizedCache cache = new SynchronizedCache();
        CacheConfig cacheConfig = new CacheConfigImpl("cacheId", null, 0, 0, 0, 0, null, "lru", "strong");
        cache.setCacheConfig(cacheConfig);

        Object key = "key";
        Object value = "value";

        cache.put(key, value);
        cache.clear();

        return cache.get(key)==null ? true : false;
    }
View Full Code Here

    /**
     * ������������� ������������ ���������� ��������� � ����. �������� ������ ��� ����������.
     * ����������� ������ ���� ������������ ���������� ��������.
     */
    public static boolean test_MAXSIZE() throws Exception {
        SynchronizedCache cache = new SynchronizedCache();
        int maxSize = 100;
        CacheConfig cacheConfig = new CacheConfigImpl("cacheId", null, 0, 0, 0, maxSize, null, "lru", "strong");
        cache.setCacheConfig(cacheConfig);

        for (int i = 0, maxi = maxSize*2; i <maxi; i++) {
            cache.put(new Long(i), new Long(i));
        }

        return cache.size()==maxSize ? true : false;
    }
View Full Code Here

     * �������� ������� ������� �������� ����� ��� ��������� ������������ ������.
     * � ���������� ������� � ���� ������ �������� ������ �� �����������
     * ������������.
     */
    public static boolean test_MAXMEMORYSIZE() throws Exception {
        SynchronizedCache cache = new SynchronizedCache();
        int msxMemorySize = 1000;
        CacheConfig cacheConfig = new CacheConfigImpl("cacheId", null, 0, 0, msxMemorySize, 0, null, "lru", "strong");
        cache.setCacheConfig(cacheConfig);

        for (int i = 0; i <1000; i++) {
            cache.put(new Long(i), new Long(i));
        }

        return cache.getCacheInfo().getMemorySize()<=msxMemorySize ? true : false;
    }
View Full Code Here

     * �������� ������� �������� ����� ��� ��������� ������������ ���������� � �����.
     * � ���������� ���������� �������� � ����� �� ������ ��������� ������������
     * ��������.
     */
    public static boolean test_MAXSIZE_AND_MAXMEMORYSIZE() throws Exception {
        SynchronizedCache cache = new SynchronizedCache();
        int maxMemorySize = 1000;
        int maxSize = 1000;
        CacheConfig cacheConfig = new CacheConfigImpl("cacheId", null, 0, 0, maxMemorySize, maxSize, null, "lru", "strong");
        cache.setCacheConfig(cacheConfig);

        for (int i = 0; i <maxSize*2; i++) {
            cache.put(new Long(i), new Long(i));
        }

        return cache.getCacheInfo().getMemorySize()<=maxMemorySize && cache.size()<=maxSize ? true : false;
    }
View Full Code Here

     * ������������� ������������ ����� ����� �������. �������� ������.
     * ������������� ����� �� ����� ����������� ������������ �����.
     * � ���������� ��� ������ ������� null.
     */
    public static boolean test_TTL() throws Exception {
        SynchronizedCache cache = new SynchronizedCache();
        CacheConfig cacheConfig = new CacheConfigImpl("cacheId", null, 1, 0, 0, 0, null, "lru", "strong");
        cache.setCacheConfig(cacheConfig);

        Object key = "key";
        Object value = "value";

        cache.put(key, value);
        Thread.sleep(30);

        return cache.get(key)==null ? true : false;
    }
View Full Code Here

     * ������������� ������������ ����� ����������� �������. �������� ������.
     * ������������� ����� �� ����� ����������� ������������ �����.
     * � ���������� ��� ������ ������� null.
     */
    public static boolean test_IDLE() throws Exception {
        SynchronizedCache cache = new SynchronizedCache();
        CacheConfig cacheConfig = new CacheConfigImpl("cacheId", null, 0, 1, 0, 0, null, "lru", "strong");
        cache.setCacheConfig(cacheConfig);

        Object key = "key";
        Object value = "value";

        cache.put(key, value);
        Thread.sleep(30);

        return cache.get(key)==null ? true : false;
    }
View Full Code Here

        CacheFactory cf = CacheFactory.getInstance();
        long ttl = 100;
        long cleanInterval = ttl*2;
        long sleep = ttl*3;

        SynchronizedCache cache = new SynchronizedCache();
        CacheConfig cacheConfig = new CacheConfigImpl("cacheId", null, ttl, 0, 0, 0, null, "lru", "strong");
        cache.setCacheConfig(cacheConfig);

        for (int i = 0; i <1000; i++) {
            cache.put(new Long(i), new Long(i));
        }

        cf.addCache(cache);
        cf.setCleanInterval(cleanInterval);
        Thread.sleep(sleep);

        return cache.size()==0 ? true : false;
    }
View Full Code Here

TOP

Related Classes of net.sf.cache4j.impl.SynchronizedCache

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.