JCS 2.2 - able to write/retrieve from disk, but not from memory

127 views Asked by At

I'm a beginner to JCS, though I am somewhat familiar with Java and Eclipse (which is what I'm using to code). I'm trying to create a caching system that will store elements in the memory cache first before storing elements in the disk cache (when the memory cache has run out of room).

Whenever I add elements and send them directly to the disk, then rerun the test to retrieve that element (without adding it first), it retrieves it without a problem. But when I add an element to the memory cache, then rerun and see if it can be retrieved (without adding, to see if the key/value remains in the cache), it's not retrieved.

Is there a reason this is happening? I've set the LRU cache attribute IsEternal to true, so the elements shouldn't be expiring.

EDIT: To add onto this, is memory in general not supposed to allow persistence of data?

And in JCS, is it not possible to use custom/complex keys from a class I created? I'd like to use a class called TileCoordinates I made (which contains X and Y coordinates) as the key, but whenever I add and retrieve a value for this type of key, I simply get null.

Any help is appreciated!

0

There are 0 answers