|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Pluggable Disk StoresI would like to use EHCache, but, also want it to back to a database instead of disk when the in-memory cache overflows. I saw a feature on the road map for 'Pluggable Disk Stores'. Has this been implemented yet? Anyone else looked into such functionality? Thanks Tim ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ ehcache-list mailing list ehcache-list@... https://lists.sourceforge.net/lists/listinfo/ehcache-list |
|
|
Re: Pluggable Disk StoresTim The diskStore is reference as a Store in the main ehcache. I did this to move towards pluggability for the DiskStore, but never had a second implementation so never made it pluggable in configuration. You should however be able to subclass cache and override: /** * Creates a disk store when either: * <ol> * <li>overflowToDisk is enabled * <li>diskPersistent is enabled * </ol> */ protected Store createDiskStore() { if (isDiskStore()) { return new DiskStore(this, diskStorePath); } else { return null; } } Then you can put your DatabaseDiskStore cache back in CacheManager with: /** * Replaces in the map of Caches managed by this CacheManager an Ehcache with a decorated version of the same * Ehcache. CacheManager can operate fully with a decorated Ehcache. * <p/> * Ehcache Decorators can be used to obtain different behaviour from an Ehcache in a very flexible way. Some examples in * ehcache are: * <ol> * <li>{@link net.sf.ehcache.constructs.blocking.BlockingCache} - A cache that blocks other threads from getting a null element until the first thread * has placed a value in it. * <li>{@link net.sf.ehcache.constructs.blocking.SelfPopulatingCache} - A BlockingCache that has the additional * property of knowing how to load its own entries. * </ol> * Many other kinds are possible. * <p/> * It is generally required that a decorated cache, once constructed, is made available to other execution threads. * The simplest way of doing this is to substitute the original cache for the decorated one here. * <p/> * Note that any overwritten Ehcache methods will take on new behaviours without casting. Casting is only required * for new methods that the decorator introduces. * For more information see the well known Gang of Four Decorator pattern. * * @param ehcache * @param decoratedCache An implementation of Ehcache that wraps the original cache. * @throws CacheException if the two caches do not equal each other. */ public synchronized void replaceCacheWithDecoratedCache(Ehcache ehcache, Ehcache decoratedCache) throws CacheException { if (!ehcache.equals(decoratedCache)) { throw new CacheException("Cannot replace " + decoratedCache.getName() + " It does not equal the incumbent cache."); } else { String cacheName = ehcache.getName(); ehcaches.remove(cacheName); caches.remove(cacheName); ehcaches.put(decoratedCache.getName(), decoratedCache); if (decoratedCache instanceof Cache) { caches.put(decoratedCache.getName(), decoratedCache); } } } There is a patch that does this for Derby. See http://sourceforge.net/tracker/index.php?func=detail&aid=1727946&group_id=93232&atid=603561 On 29/05/2008, at 11:39 PM, Tim Langford wrote:
Regards Greg Luck web: http://gregluck.com skype: gregrluck yahoo: gregrluck mobile: +61 408 061 622------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ ehcache-list mailing list ehcache-list@... https://lists.sourceforge.net/lists/listinfo/ehcache-list |
| Free Forum Powered by Nabble | Forum Help |