JCache API works only until expired. After expiration values are never
re-added. How to configure it that values could be allways be added an
fetched from it?
public class Test {
Cache cache;
public Test() {
Map props = new HashMap();
props.put(GCacheFactory.EXPIRATION_DELTA_MILLIS, 10000);
props.put(MemcacheService.SetPolicy.SET_ALWAYS, true);
cache = CacheManager.getInstance().getCacheFactory().createCache
(props);
}
public String testCache() {
String testDoc = (String) cache.get("test-doc"); // is there
only
10 s
System.out.println(" test-doc found in cache: " + testDoc);
if (testDoc == null) {
testDoc = "This is a Test.";
cache.put("test-doc", testDoc); // never readed after
expiration
System.out.println("doc. added to cache.");
}
return testDoc;
}
}
http://javathings.blogspot.com/2009/07/cache-expiration-in-google-app-engine.html
...configuration property EXPIRATION_DELTA which you provided when
creating the cache instance, is treated as number of seconds after
which the entire cache instance is expired.
The workaround is to use Low-level API for Memcache and it even
supports different expiration time for different objects that you put
in cache - you can optionally specify expiration time when you add
objects to cache.
How to obtain a Low-level Memcache instance?
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.