1 18 19 package org.apache.roller.util.cache; 20 21 import java.util.Map ; 22 import org.apache.commons.logging.Log; 23 import org.apache.commons.logging.LogFactory; 24 25 26 29 public class ExpiringLRUCacheFactoryImpl implements CacheFactory { 30 31 private static Log log = LogFactory.getLog(ExpiringLRUCacheFactoryImpl.class); 32 33 34 protected ExpiringLRUCacheFactoryImpl() {} 36 37 38 41 public Cache constructCache(Map properties) { 42 43 int size = 100; 44 long timeout = 15 * 60; 45 String id = "unknown"; 46 47 try { 48 size = Integer.parseInt((String ) properties.get("size")); 49 } catch(Exception e) { 50 } 52 53 try { 54 timeout = Long.parseLong((String ) properties.get("timeout")); 55 } catch(Exception e) { 56 } 58 59 String cacheId = (String ) properties.get("id"); 60 if(cacheId != null) { 61 id = cacheId; 62 } 63 64 Cache cache = new ExpiringLRUCacheImpl(id, size, timeout); 65 66 log.debug("new cache constructed. size="+size+", timeout="+timeout); 67 68 return cache; 69 } 70 71 } 72 | Popular Tags |