1 5 package com.opensymphony.oscache.general; 6 7 import com.opensymphony.oscache.base.*; 8 9 import org.apache.commons.logging.Log; 10 import org.apache.commons.logging.LogFactory; 11 12 import java.util.Date ; 13 import java.util.Properties ; 14 15 78 public class GeneralCacheAdministrator extends AbstractCacheAdministrator { 79 private static transient final Log log = LogFactory.getLog(GeneralCacheAdministrator.class); 80 81 84 private Cache applicationCache = null; 85 86 89 public GeneralCacheAdministrator() { 90 this(null); 91 } 92 93 96 public GeneralCacheAdministrator(Properties p) { 97 super(p); 98 log.info("Constructed GeneralCacheAdministrator()"); 99 createCache(); 100 } 101 102 107 public Cache getCache() { 108 return applicationCache; 109 } 110 111 116 public void removeEntry(String key) { 117 getCache().removeEntry(key); 118 } 119 131 public Object getFromCache(String key) throws NeedsRefreshException { 132 return getCache().getFromCache(key); 133 } 134 135 150 public Object getFromCache(String key, int refreshPeriod) throws NeedsRefreshException { 151 return getCache().getFromCache(key, refreshPeriod); 152 } 153 154 172 public Object getFromCache(String key, int refreshPeriod, String cronExpression) throws NeedsRefreshException { 173 return getCache().getFromCache(key, refreshPeriod, cronExpression); 174 } 175 176 183 public void cancelUpdate(String key) { 184 getCache().cancelUpdate(key); 185 } 186 187 190 public void destroy() { 191 finalizeListeners(applicationCache); 192 } 193 194 196 199 public void flushAll() { 200 getCache().flushAll(new Date ()); 201 } 202 203 208 public void flushAll(Date date) { 209 getCache().flushAll(date); 210 } 211 212 215 public void flushEntry(String key) { 216 getCache().flushEntry(key); 217 } 218 219 224 public void flushGroup(String group) { 225 getCache().flushGroup(group); 226 } 227 228 236 public void flushPattern(String pattern) { 237 getCache().flushPattern(pattern); 238 } 239 240 247 public void putInCache(String key, Object content, EntryRefreshPolicy policy) { 248 Cache cache = getCache(); 249 cache.putInCache(key, content, policy); 250 } 251 252 258 public void putInCache(String key, Object content) { 259 putInCache(key, content, (EntryRefreshPolicy) null); 260 } 261 262 269 public void putInCache(String key, Object content, String [] groups) { 270 getCache().putInCache(key, content, groups); 271 } 272 273 281 public void putInCache(String key, Object content, String [] groups, EntryRefreshPolicy policy) { 282 getCache().putInCache(key, content, groups, policy, null); 283 } 284 285 292 public void setCacheCapacity(int capacity) { 293 super.setCacheCapacity(capacity); 294 getCache().setCapacity(capacity); 295 } 296 297 300 private void createCache() { 301 log.info("Creating new cache"); 302 303 applicationCache = new Cache(isMemoryCaching(), isUnlimitedDiskCache(), isOverflowPersistence(), isBlocking(), algorithmClass, cacheCapacity); 304 305 configureStandardListeners(applicationCache); 306 } 307 } 308 | Popular Tags |