01: package org.shiftone.cache.util;
02:
03: import org.shiftone.cache.Cache;
04: import org.shiftone.cache.CacheFactory;
05: import org.shiftone.cache.decorator.sync.SyncCache;
06: import org.shiftone.cache.util.reaper.CacheReaper;
07: import org.shiftone.cache.util.reaper.ReapableCache;
08:
09: /**
10: * @version $Revision: 1.1 $
11: * @author $Author: jeffdrost $
12: */
13: public abstract class AbstractPolicyCacheFactory implements
14: CacheFactory {
15:
16: private static final Log LOG = new Log(
17: AbstractPolicyCacheFactory.class);
18: private int period = 1000;
19:
20: public abstract ReapableCache newReapableCache(String cacheName,
21: long timeoutMilliSeconds, int maxSize);
22:
23: public Cache newInstance(String cacheName,
24: long timeoutMilliSeconds, int maxSize) {
25:
26: return CacheReaper.register( //
27: new SyncCache( //
28: newReapableCache(cacheName,
29: timeoutMilliSeconds, maxSize)), //
30: period);
31: }
32:
33: /**
34: * time in milliseconds between calls from the reaper. Every "period"
35: * milliseconds this factory's reaper will wake up and call
36: * "removeExpiredElements" on the cache. Note that changing this value will
37: * only effect new caches - all existing caches will continue with the same
38: * period.
39: */
40: public int getPeriod() {
41: return period;
42: }
43:
44: public void setPeriod(int period) {
45: this.period = period;
46: }
47: }
|