[jboss-user] [JBoss Cache] - How to do jboss caching

Amol Umrani do-not-reply at jboss.com
Wed Aug 25 02:20:31 EDT 2010


Amol Umrani [http://community.jboss.org/people/amolumrani] replied to the discussion

"How to do jboss caching"

To view the discussion, visit: http://community.jboss.org/message/558885#558885

--------------------------------------------------------------
Hello Navin,

Thanks for help.

I am doing as follows..

public class SimpleCaching
{
    try
    {
        GlobalConfiguration myGlobalConfig = new GlobalConfiguration();
        // configure myGlobalConfig accordingly
        EmbeddedCacheManager manager = new DefaultCacheManager(myGlobalConfig);

        Configuration config = new Configuration();
        // configure your config bean accordingly
        manager.defineConfiguration("myCustomCache", config);
        Cache customCache = manager.getCache("myCustomCache");


        customCache.put("key", "value");

        customCache.containsKey("key");
        customCache.remove("key");

        customCache.isEmpty();

        // remember that Cache extends ConcurrentMap!

        customCache.put("key", "value");
        customCache.putIfAbsent("key", "newValue");
        customCache.clear();
    }catch(CacheException ex){
        System.out.println(ex.getMessage());
    }
}

This is as per 5 minutes tutorial of infinispan.

My question is it right way to write the code for caching...

We are using JPA and i come to know we required to configure infinispan for second level cache in persistence.xml..

so in this code where i should pass this xml?

Please help me regarding this..


Thnks,
Amol

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/558885#558885]

Start a new discussion in JBoss Cache at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2052]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100825/1f518e4c/attachment.html 


More information about the jboss-user mailing list