[Opensymphony-oscache] why i can still get the cached object after flushEntry(key) is called?
DavidZhang <[email protected]> Wed, 18 May 2005 04:33:04 CDT
| Newsgroups | gmane.comp.java.open-symphony.os-cache |
|---|---|
| Message-ID | <33341537.1116408814481.JavaMail.os-j2ee@opensymphony01.contegix.com> |
Hi,
I am using OSCache in my project, and recently we have found a problem, in order to demonstrate the problem, i have wrote a small test program:
package cache.test;
import com.opensymphony.oscache.base.CacheEntry;
import com.opensymphony.oscache.general.GeneralCacheAdministrator;
public class TestOSCache {
public static void main(String[] args) throws Exception {
GeneralCacheAdministrator cache = new GeneralCacheAdministrator();
cache.putInCache("0", "0");
cache.putInCache("1", "1");
cache.putInCache("2", "2");
cache.putInCache("3", "3");
cache.putInCache("4", "4");
cache.putInCache("5", "5");
cache.putInCache("6", "6");
cache.putInCache("7", "7");
cache.putInCache("8", "8");
cache.putInCache("9", "9");
cache.flushEntry("1");
try {
System.out.println("a" + cache.getCache().getFromCache("1", CacheEntry.INDEFINITE_EXPIRY));
}catch (Exception e) {
e.printStackTrace(System.out);
}
try {
System.out.println("b" + cache.getFromCache("1", CacheEntry.INDEFINITE_EXPIRY));
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
}
the result is:
2005-05-18 17:20:32,584 Properties {cache.algorithm=com.opensymphony.oscache.base.algorithm.UnlimitedCache, cache.capacity=1000000, cache.memory=true}
2005-05-18 17:20:32,584 Constructed GeneralCacheAdministrator()
2005-05-18 17:20:32,584 Creating new cache
com.opensymphony.oscache.base.NeedsRefreshException
at com.opensymphony.oscache.base.Cache.getFromCache(Cache.java:309)
at com.opensymphony.oscache.base.Cache.getFromCache(Cache.java:205)
at cache.test.TestOSCache.main(TestOSCache.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
b1
our problem is why we can still get the object at point b after cache.flushEntry("1") has been called?
Thanks!
David Zhang
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=2321&messageID=6780#6780