How to use infinispan as a caching engine

There are many popular caching engines available in the market like redis, ehcache, memcached, jcs etc. In this article we will be covering infinispan.

  1. Download inifinispan server from . Go for ‘server’
  2. Go to bin directory of the server and run or bat file depending upon your operating system
  3. Here is the java code to insert and get the keyRemoteCacheManager manager = new RemoteCacheManager(); RemoteCache<Object, Object> c = manager.getCache(“sellersCache”); String key =”key”; String value = “value”; c.put(key,value,1000, TimeUnit.SECONDS); c.remove(key); System.out.println(c.get(key)); try { Thread.sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println(c.get(key));
  4. You can also check the admin console to monitor cache. Run add-user.bat file from bin folder to create a user
  5. Go to http://localhost:9990 and login as a user you created in step 4. Now you can monitor all your caches

Leave a Reply

Your email address will not be published. Required fields are marked *