1 package org.shiftone.cache.adaptor; 2 3 4 5 import org.shiftone.cache.Cache; 6 import org.shiftone.cache.CacheFactory; 7 import org.shiftone.cache.policy.zero.ZeroCacheFactory; 8 import org.shiftone.cache.util.Log; 9 10 11 17 public class OroCacheFactory implements CacheFactory 18 { 19 20 private static final Log LOG = new Log(OroCacheFactory.class); 21 public static String ALGORITHM_FIFO = "FIFO"; 22 public static String ALGORITHM_FIFO2 = "FIFO2"; 23 public static String ALGORITHM_LRU = "LRU"; 24 public static String ALGORITHM_RANDOM = "RANDOM"; 25 private String algorithm = ALGORITHM_LRU; 26 27 public Cache newInstance(String cacheName, long timeoutMilliSeconds, int maxSize) 28 { 29 30 if (ALGORITHM_FIFO.equalsIgnoreCase(algorithm)) 31 { 32 return OroCache.createFIFO(maxSize); 33 } 34 else if (ALGORITHM_FIFO2.equalsIgnoreCase(algorithm)) 35 { 36 return OroCache.createFIFO2(maxSize); 37 } 38 else if (ALGORITHM_LRU.equalsIgnoreCase(algorithm)) 39 { 40 return OroCache.createLRU(maxSize); 41 } 42 else if (ALGORITHM_RANDOM.equalsIgnoreCase(algorithm)) 43 { 44 return OroCache.createRandom(maxSize); 45 } 46 else 47 { 48 LOG.info("unknown ORO cache algorithm : " + algorithm); 49 50 return ZeroCacheFactory.NULL_CACHE; 51 } 52 } 53 54 55 public String getAlgorithm() 56 { 57 return algorithm; 58 } 59 60 61 64 public void setAlgorithm(String algorithm) 65 { 66 this.algorithm = algorithm; 67 } 68 } 69 | Popular Tags |