Hello
Before I used a previous version of JBoss Cache where I simply could use in every bean:
@In(create=true)CacheProvider cacheProvider
public void method(){
...
List) cacheProvider.get("tree-"+id);
if (rubriek == null){
cacheProvider.put("tree-"+id,getTree());
}
...
}
and the caching worked just fine through the whole site.
Now I'm trying to work with JBoss Cache 3.2.5.GA and it's not working. Every time I click on a button, the cache is empty.
What I did were these steps:
I started changing the code in each bean into
CacheFactory factory = new DefaultCacheFactory();Cache cache = factory.createCache("cache-configuration.xml"); public void method(){ ... List) cache.get(fqn,"tree"); if (rubriek == null){ cache.put(fqn,"tree",getTree()); } ...}
When I tried this code, I saw that the cache was each time emptied when I hit a button. I thought I could come because I start in each bean a new Cache by using factory.createCache("cache-configuration.xml")
So I made a new class that can be used in every bean and so that the cache is only started once
public class CacheHelper{
public static CacheFactory factory = new DefaultCacheFactory();
public static Cache cache = factory.createCache("cache-configuration.xml");
}
public void method(){
...
but the cache is still empty each time I hit a button.
Is there anyone who can tell me what I'm doing wrong?
Thanks in advance!
barbara
O, and this is my cache-configuration.xml