[jboss-user] [JBossCache] - How to, Flush data stored in TreeCache to disk?
sjeevan
do-not-reply at jboss.com
Fri Nov 17 23:57:21 EST 2006
Hi,
I am using JE BerkleyDB implementation of JBossTreeCache (org.jboss.cache.TreeCache) in my application for storing some information.
A sniipet out of the constructor:
| public final Fqn CREATED_DATE_FQN;
| private static final String CREATED_DATE = "CreatedDate";
| ....
|
| this.cache = new TreeCache();
| cache.setClusterName(name);
| cache.setCacheMode("local");
| cache.setCacheLoaderConfiguration(getSingleCacheLoaderConfig("",
| BdbjeCacheLoader.class.getName(), "location="
| + f.getAbsolutePath(), false, true, false));
| cache.startService();
| cache.put(CREATED_DATE_FQN, CREATED_DATE, new Timestamp(new Date().getTime()));
| cache.load(name);//Load existing data if any
| ...
| cache.startService(); /// required before the cache can be used!
| ...
|
|
To store data I use:
| cache.put(MAX_ID_FQN, MAX_ID, eventId);
|
But what I have observed is that the cache is not flushed to disk.
I have discovered a workaround (but unacceptable for production) is, after every put;
| cache.put(MAX_ID_FQN, MAX_ID, eventId);
| // stopService & startSerivice of cache, to flush the data just added to disk
| cache.stopService();
| cache.startService();
|
I tried commit() after the put
| cache.put(MAX_ID_FQN, MAX_ID, eventId);
| cache.commit(cache.getCurrentTransaction(true)); //commit to disk, but this throws an exception
|
but that throws a
java.lang.UnsupportedOperationException::commit() should not be called on TreeCache directly.
Any clues will be appreciated.
~g1
PS: To build I use maven with jboss-cache-1.4.0.SP1.jar, jboss-system-4.0.3.jar, jboss-jmx-4.0.3.jar & jboss-common-4.0.3.jar
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3987041#3987041
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3987041
More information about the jboss-user
mailing list