[Opensymphony-oscache] Urgent help required: Disk caching problem
mldf <[email protected]>
| Newsgroups | gmane.comp.java.open-symphony.os-cache |
|---|---|
| Message-ID | <24140917.1111095310198.JavaMail.os-j2ee@opensymphony01.contegix.com> |
In case you want to see my original problem, here is my test case:
public class GeneralCache extends Cache {
public GeneralCache(boolean useMemoryCaching, boolean unlimitedDiskCache, boolean overflowPersistence)
{
super(useMemoryCaching, unlimitedDiskCache, overflowPersistence);
}
public void removeEntry(String key)
{
super.removeEntry(key);
}
}
public class GeneralCacheTest extends TestCase {
GeneralCache cacheObj;
public GeneralCacheTest(String testName)
{
super(testName);
}
public static void main(String[] args)
{
junit.textui.TestRunner.run(suite());
}
public static Test suite()
{
TestSuite suite = new TestSuite(GeneralCacheTest.class);
return suite;
}
protected void setUp() throws Exception
{
Properties prop = new Properties();
prop.put("cache.memory", "true");
prop.put("cache.blocking", "true");
prop.put("cache.unlimited.disk", "true");
prop.put("cache.path", "C:\\temp");
prop.put("cache.persistence.overflow.only","true");
prop.put("cache.persistence.class", "com.opensymphony.oscache.plugins.diskpersistence.HashDiskPersistenceListener");
Config config = new Config(prop);
PersistenceListener listener = new com.opensymphony.oscache.plugins.diskpersistence.HashDiskPersistenceListener();
listener = listener.configure(config);
cacheObj = new GeneralCache(true, true, true);
cacheObj.setPersistenceListener(listener);
cacheObj.setCapacity(1);
}
/* test PutInCache */
public void testPutInCache() throws Exception
{
int n = 4;
String key = null;
String value = null;
// cache is empty now, each get will throw exception and new entry is put
for(int i = 0; i < n; i++)
{
key = "key " + i;
try
{
// Get from the cache
value = cacheObj.getFromCache(key).toString();
assertTrue(false); // this line shouldn't be reached
}
catch (NeedsRefreshException nre)
{
try
{
// Store in the cache
value = "test value " + i;
cacheObj.putInCache(key, value);
}
catch(Exception e)
{
System.out.println(e.toString());
cacheObj.cancelUpdate(key);
System.out.println("cancelUpdate called");
}
}
}
}
After the test, none is saved in disk.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=648&messageID=2860#2860