1 10 11 package net.sf.cache4j.perfomance.cache; 12 13 import net.sf.cache4j.perfomance.ICache; 14 15 import java.util.Properties ; 16 17 import org.apache.log4j.PropertyConfigurator; 18 import org.apache.jcs.JCS; 19 20 26 27 public class jcs implements ICache { 28 private JCS _cache; 31 33 public static final String NAME = "jcs 1.2.7.0"; 34 35 38 42 public void init() throws Exception { 43 Properties prop = new Properties (); 44 prop.put("log4j.logger.org.apache.jcs", "fatal, jcs"); 45 prop.put("log4j.appender.jcs", "org.apache.log4j.ConsoleAppender"); 46 prop.put("log4j.appender.jcs.layout", "org.apache.log4j.PatternLayout"); 47 prop.put("log4j.appender.jcs.layout.ConversionPattern", "%d %-5p%m%n"); 48 PropertyConfigurator.configure(prop); 49 50 _cache = JCS.getInstance("default"); 51 } 52 53 59 public Object get(Object id) throws Exception { 60 return _cache.get(id); 61 } 62 63 69 public void put(Object id, Object value) throws Exception { 70 _cache.put(id, value); 71 } 72 73 78 public void remove(Object id) throws Exception { 79 _cache.remove(id); 80 } 81 82 87 public long size() throws Exception { 88 return 0; 89 } 90 91 94 public void destroy() { 95 try { 96 _cache.clear(); 97 _cache = null; 98 } catch (Exception e){ 99 e.printStackTrace(); 100 } 101 } 102 103 107 public String getCacheName() { 108 return NAME; 109 } 110 111 } | Popular Tags |