how insert set of hashmaps cache?
after executing below code got below exception.
net.sf.jsr107cache.cacheexception: not find class: 'ri.cache.basiccachefactory' @ net.sf.jsr107cache.cachemanager.getcachefactory(cachemanager.java:46) @ insertintocache.main(insertintocache.java:17)
i want insert hashmap value string key.any hugely appreciated
import java.io.ioexception; import java.util.hashmap; import java.util.collections; import net.sf.jsr107cache.cache; import net.sf.jsr107cache.cacheexception; import net.sf.jsr107cache.cachefactory; import net.sf.jsr107cache.cachemanager; public class insertintocache { public static void main(string[] args) throws ioexception { cache cache; try { cachefactory cachefactory = cachemanager.getinstance().getcachefactory(); cache = cachefactory.createcache(collections.emptymap()); string key="21"; byte[] value=("twenty one").getbytes(); cache.put(key, value); value = (byte[]) cache.get(key); system.out.println(value); } catch (cacheexception e) { e.printstacktrace(); } } }
i suggest using imcache. can construct cache follows,
cache<string, string> cache = cachebuilder.concurrentheapcache().build();
Comments
Post a Comment