JBoss Community

How to do jboss caching

reply from Navin Surtani in JBoss Cache - View the full discussion

Hey Amol,


1) I am going through http://community.jboss.org/wiki/5minutetutorialonInfinispan.

 

I have download infinispan-4.1.0.CR3-all.zip from their site.

 

I want to see how object caching is done by infinispan.

 

bcoz of am new to caching can u tell me how to deploy this tutorial?

 

I have tried GUI Demo of Infinispan but not getting enough idea of object caching.

 


 

 


What do you mean by Object caching? Do you mean actually how you put stuff into the cache and making use of it?

 

If so you can just do something like: -

 

 

CacheManager cm = new DefaultCacheManager();
Cache<MySpecialKey, MySpecialValue> c = cm.getCache();
 
 
// Put some stuff into the cache
c.put(k1, v1);
 
//etc etc

 

Now I want to get the stuff out of the cache using a different app on a different JVM even. {Note that this will only work if the Caches are in DIST or REPL configuration and have the SAME configuration. Also note that the caches have the same String name in both cases}

 

 

CacheManager cm2 = new DefaultCacheManager();
Cache<MySpecialKey, MySpecialValue> c = cm2.getCache();
 
// Get my stuff out of the cache: - 
 
MySpecialValue specialValue = c.get(k1);
 
// etc etc

 

 

Obviously if that's not what you want and have a more complex problem then please let me know and I'll see if I can help.

 

With respect to the configuration file, as long as it's somewhere in your project directory it should be fine. Generally a good idea to keep it with your maven/ant build file or a config directory if you have one. Make sure you use the appropriate API on CacheManager though.

 

Hope that helps,

Navs.

Reply to this message by going to Community

Start a new discussion in JBoss Cache at Community