try {
int port = ERXProperties.intForKeyWithDefault("er.caching.server.port", 0);
if(port > 0) {
int maxItems = ERXProperties.intForKeyWithDefault("er.caching.server.maxItems", 0);
int maxMemory = ERXProperties.intForKeyWithDefault("er.caching.server.maxMemory", 128);
MemCacheDaemon daemon = new MemCacheDaemon();
LRUCacheStorageDelegate cacheStorage = new LRUCacheStorageDelegate(maxItems, maxMemory * 1024*1024, 0);
daemon.setCache(new Cache(cacheStorage));
String host = ERXProperties.stringForKeyWithDefault("er.caching.server.host", WOApplication.application().host());
daemon.setAddr(new InetSocketAddress(host, port));
daemon.setIdleTime(50);
daemon.setVerbose(true);
daemon.start();
log.info("Server started: " + host + ":" + port + " maxItems=" + maxItems + " maxMemory=" + maxMemory);
}
} catch (IOException e) {
throw NSForwardException._runtimeExceptionForThrowable(e);
}