Package org.shiftone.cache

Examples of org.shiftone.cache.CacheFactory


    private CacheFactory     delegate;

    public Cache newInstance(String cacheName, long timeoutMs, int maxSize)
    {

        CacheFactory factory = getDelegate();
        Cache        cache   = null;

        try
        {
            cache = factory.newInstance(cacheName, timeoutMs, maxSize);

            if (factory != null)
            {
                cache = wrapDelegate(cacheName, cache);
            }
View Full Code Here


    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;
        int          threads          = 1;      // running worker threads
        int          cycles           = 100;    // cycles per thread
        int          gpc              = 5;      // gets per cycle
        int          ppc              = 5;      // puts per cycle
        Thrasher     thrasher         = null;

        for (int i = 0; i < args.length; i++)
        {
            LOG.message("arg[ " + i + " ] = " + args[i]);
        }

        for (int i = 0; i < args.length; i++)
        {
            if ("-factory".equalsIgnoreCase(args[i]))
            {
                factoryClassName = args[++i];
            }

            if ("-size".equalsIgnoreCase(args[i]))
            {
                size = Integer.parseInt(args[++i]);
            }

            if ("-ttl".equalsIgnoreCase(args[i]))
            {
                ttl = Integer.parseInt(args[++i]);
            }

            if ("-threads".equalsIgnoreCase(args[i]))
            {
                threads = Integer.parseInt(args[++i]);
            }

            if ("-cycles".equalsIgnoreCase(args[i]))
            {
                cycles = Integer.parseInt(args[++i]);
            }

            if ("-gpc".equalsIgnoreCase(args[i]))
            {
                gpc = Integer.parseInt(args[++i]);
            }

            if ("-ppc".equalsIgnoreCase(args[i]))
            {
                ppc = Integer.parseInt(args[++i]);
            }
        }

        factoryClass = Class.forName(factoryClassName);
        cacheFactory = (CacheFactory) factoryClass.newInstance();
        cache        = cacheFactory.newInstance("thrasher", ttl, size);
        thrasher     = new Thrasher(cache, threads);

        thrasher.thrash();
    }
View Full Code Here

    private static final Log LOG = new Log(ReaperTestCase.class);

    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);
View Full Code Here

    public void testProxy() throws Exception
    {

        List         list    = new ArrayList();
        CacheFactory factory = new SingleCacheFactory();
        Cache        cache   = factory.newInstance("proxyTest", 1000, 1);
        List         plist   = (List) CacheProxy.newProxyInstance(list, List.class, cache);

        System.out.println(plist.size());
        System.out.println(plist.add("test1"));
        System.out.println(plist.add("test2"));
View Full Code Here

    {

        String       name             = factoryNode.getKey();
        String       factoryClassName = factoryNode.getValue();
        Class        factoryClass;
        CacheFactory cacheFactory;

        try
        {
            factoryClass = Class.forName(factoryClassName);
            cacheFactory = (CacheFactory) factoryClass.newInstance();
View Full Code Here

    private void setFactoryProperties(Node factoryNode) throws ConfigurationException
    {

        String       name         = factoryNode.getKey();
        CacheFactory cacheFactory = getFactory(name);
        BeanWrapper  wrapper      = new BeanWrapper(cacheFactory);
        Iterator     iterator     = factoryNode.getChildren().iterator();
        Node         node;

        while (iterator.hasNext())
View Full Code Here


    private void setFactoryProperty(String cacheName, BeanWrapper factoryWrapper, String name, String value) throws ConfigurationException
    {

        CacheFactory factory;

        try
        {
            Class type = factoryWrapper.getType(name);
View Full Code Here

    private Cache            theTestCache;

    public MissHandlingCache createCache()
    {

        CacheFactory             cacheFactory     = new FifoCacheFactory();
        MissHandlingCacheFactory missCacheFactory = new MissHandlingCacheFactory();

        missCacheFactory.setDelegate(cacheFactory);
        missCacheFactory.setMissHandlerClass(TestMissHandler.class);
View Full Code Here

    public void testCluster() throws Exception
    {

        CacheConfiguration config   = new CacheConfiguration();
        CacheFactory       factoryA = config.getCacheFactory("clusterA");
        CacheFactory       factoryB = config.getCacheFactory("clusterB");
        Cache              oneA     = factoryA.newInstance("one", 1000, 1000);
        Cache              oneB     = factoryB.newInstance("one", 1000, 1000);

        for (int i = 0; i < 1000; i++)
        {
            oneA.addObject("key" + i, "value");
            oneB.addObject("key" + i, "value");
View Full Code Here

TOP

Related Classes of org.shiftone.cache.CacheFactory

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.