-
1. Re: Override FileCacheStore
manik Oct 15, 2009 6:43 AM (in response to syg6)The BucketBasedCacheStore actually stores stuff in a bucket, named on the hashcode of the key. So multiple entries whose keys share the same hashcode will be in the same bucket. The FileCacheStore extends the BucketBasedCacheStore to write this bucket to a file, so you would have files named "1", as that would be the hashcode of the key "1".
If you wanted to change this, you would have to implement CacheStore directly, or perhaps extend AbstractCacheStore. Not BucketBasedCacheStore. -
2. Re: Override FileCacheStore
syg6 Oct 16, 2009 7:20 AM (in response to syg6)Hmmm. But of course if I do the following:
cache.put(1, "hello");
cache.put(1, "world");
I have exactly one file with the name "1" in my store, whose contents are "world" because the second put over-writes the first. That's how the cache works, so I'm not sure how to tell the Bucket to do otherwise.
But it doesn't matter really because we are realizing that our definition of a store isn't Infinispan's. Infinispan uses the store to a) save items that don't fit in the cache, once the cache becomes bigger than the max size allowed, and b) to load data off the disk (or database) at startup.
We, on the other hand, want to create a memory cache that contains a String id and a small POJO value. Within this POJO is the path on the disk (an NFS mount, shared between cluster members) where this item's corresponding XML file is stored. We then load the XML file. We can't store the XML files themselves in the cache, there are hundreds of thousands of them, even millions, and they can way up to 10 Mb or more. So we store them on disk.
So it seems we don't really want to use Infinispan's built-it store. Rather we'd like to be able to somehow be able to use a listener or an interceptor of some kind, so that after each get/put we can automatically go to the disk and load/save the XML.
Is this possible? I've been looking at Interceptore, Visitors and VisitableCommands but I'm not really sure how to go about it.
Any help much appreciated!
Bob -
3. Re: Override FileCacheStore
manik Oct 16, 2009 7:29 AM (in response to syg6)Have a look at the Listener API:
http://docs.jboss.org/infinispan/4.0/apidocs/org/infinispan/notifications/Listener.html