-
memcached-2.4.2.jar memcached-2.4.2.jar下载
资源介绍
使用memcached 方法
package com.war.common.util;
import com.danga.MemCached.*;
import java.util.Date;
public class MemCached
{
protected static MemCachedClient mcc;
protected static Logger log;
protected static MemCached memCached = new MemCached();
protected MemCached()
{
}
public static MemCached getInstance()
{
return memCached;
}
public boolean add(String key, Object value)
{
return mcc.add(key, value);
}
public boolean add(String key, Object value, Date expiry)
{
return mcc.add(key, value, expiry);
}
public boolean replace(String key, Object value)
{
return mcc.replace(key, value);
}
public boolean replace(String key, Object value, Date expiry)
{
return mcc.replace(key, value, expiry);
}
public boolean delete(String key)
{
return mcc.delete(key);
}
public boolean delete(String key, Date expiry)
{
return mcc.delete(key, expiry);
}
public boolean keyExists(String key)
{
return mcc.keyExists(key);
}
public Object get(String key)
{
return mcc.get(key);
}
static
{
mcc = new MemCachedClient();
String servers[] = {
"127.0.0.1:11211"
};
Integer weights[] = {
new Integer(3)
};
SockIOPool pool = SockIOPool.getInstance();
pool.setServers(servers);
pool.setWeights(weights);
pool.setInitConn(5);
pool.setMinConn(5);
pool.setMaxConn(250);
pool.setMaxIdle(0x1499700L);
pool.setMaintSleep(30L);
pool.setNagle(false);
pool.setSocketTO(3000);
pool.setSocketConnectTO(0);
pool.initialize();
// mcc.setCompressEnable(true);
// mcc.setCompressThreshold(0x10000L);
mcc.set_compress_enable(true);
mcc.set_compress_threshold(0);
}
}
- 上一篇: IBM Storwize V3700 快速安装指南 V7.1
- 下一篇: ibm阵列扩容