我正在尝试将IMCache offheap与Web应用程序集成。当我运行提供的示例(添加了下面的代码)时,JVM在成功执行代码后永远不会退出。将IMCache与Web应用程序集成
OffHeapByteBufferStore bufferStore = new OffHeapByteBufferStore(8388608 ,10, 1);
final Cache<String,String> offHeapCache = CacheBuilder.offHeapCache().storage(bufferStore)
.cacheLoader(new CacheLoader<String, String>() {
public String load(String key) {
return cacheDao.load(key);
}
}).evictionListener(new EvictionListener<String, String>() {
public void onEviction(String key, String value) {
cacheDao.store(key, value);
}
}).build();
for(int i = 0; i < 1000; i++){
offHeapCache.put("key-" + i, "value - " + i);
}
System.out.println(offHeapCache.get("key-" + 100));
如何将offheap缓存与我的web应用程序集成?
@yusufaytas检查源代码,能否请您指导我这个? – jaghan
线程声音是在用户模式下创建的,但应该是守护进程。可能有一个'shutdown()'方法需要调用。 –
谢谢@BenManes。我从来没有看到任何shutdown()方法。但其他示例在完成后运行并退出JVM。 – jaghan