Package org.shiftone.cache

Examples of org.shiftone.cache.Cache


    }

    public static void main(String[] args) throws Exception
    {

        Cache        cache;
        CacheFactory cacheFactory;
        Class        factoryClass;
        String       factoryClassName = FifoCacheFactory.class.getName();
        int          size             = 100;
        int          ttl              = 2000;
View Full Code Here


{

    public void testSimple() throws Exception
    {

        Cache cache1 = new MapCache(new Hashtable());
        Cache cache2 = new SoftCache(cache1);

        cache2.addObject("key", "value");
        assertEquals("value", cache2.getObject("key"));
    }
View Full Code Here

{

    public void testSimple()
    {

        Cache  cache      = new LfuCacheFactory().newInstance("testSimple", 1000, 50);
        Object object     = new Object();
        String longString = "this is a string but it's not really that long";

        cache.addObject(longString, object);
        assertNotNull(cache.getObject(longString));
    }
View Full Code Here

    public void testSoft() throws Exception
    {

        CacheFactory factory = new FifoCacheFactory();
        Cache        cache   = factory.newInstance("test", 10000, 10000);

        LOG.info("cache = " + cache);
        cache.addObject("test", "test");
        Thread.sleep(5000);

        cache = null;

        Thread.sleep(5000);
View Full Code Here

     * Method test10000Puts
     */
    public void test10000UniquePuts()
    {

        Cache cache = newCache(1000 * 60, 1000);

        for (int i = 0; i < 10000; i++)
        {
            cache.addObject("k-" + i, "v-" + i);
        }

        assertEquals(1000, cache.size());
        cache.clear();
        assertEquals(0, cache.size());
    }
View Full Code Here

     * Method test10000Puts
     */
    public void test10000Puts()
    {

        Cache cache = newCache(1000 * 60, 1000);

        for (int i = 0; i < 10000; i++)
        {
            cache.addObject("k-" + (i % 500), "v-" + i);
        }

        assertEquals(500, cache.size());
        cache.clear();
        assertEquals(0, cache.size());
    }
View Full Code Here

     * Method test10000Puts
     */
    public void test1000Puts10000GetsSameKey()
    {

        Cache cache = newCache(1000 * 60, 500);

        for (int i = 0; i < 1000; i++)
        {
            cache.addObject("k-" + i, "v-" + i);
        }

        assertEquals(500, cache.size());

        for (int i = 0; i < 10000; i++)
        {
            assertNotNull(cache.getObject("k-987"));
        }
    }
View Full Code Here

     * Method test10000Puts99999Gets
     */
    public void test10000Puts99999Gets()
    {

        Cache  cache = newCache(1000 * 60, 1000);
        String key   = null;

        cache.addObject("k-0", "v-0");

        for (int i = 0; i < 10000; i++)
        {
            key = "k-" + (i % 200);

            cache.addObject(key, "v-" + i);
            assertNotNull(key, cache.getObject(key));
        }

        assertEquals(200, cache.size());
    }
View Full Code Here

     * Method test1Put10000GetsSameKey10Puts
     */
    public void test1Put10000GetsSameKey2Puts()
    {

        Cache cache = newCache(1000 * 60, 2);

        cache.addObject("x", "x");
        cache.addObject("y", "y");

        for (int i = 0; i < 10000; i++)
        {
            assertNotNull(cache.getObject("x"));
            assertNotNull(cache.getObject("y"));
        }

        assertEquals(2, cache.size());
        cache.addObject("a", "a");
        cache.addObject("b", "b");
        assertEquals(2, cache.size());
        assertNotNull(cache.getObject("b"));
    }
View Full Code Here

     * Method testCacheOfSize1
     */
    public void testCacheOfSize1()
    {

        Cache cache = newCache(1000 * 60, 1);

        for (int i = 0; i < 20; i++)
        {
            cache.addObject("k-" + i, "v-" + i);
        }

        assertEquals(1, cache.size());
    }
View Full Code Here

TOP

Related Classes of org.shiftone.cache.Cache

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.