标签:
public class CacheUtils { private static MemCachedClient mcc = new MemCachedClient(); private static CacheUtils utils = new CacheUtils(); static { String[] servers = {"127.0.0.1:11211"}; Integer[] weights = {3}; SockIOPool pool = SockIOPool.getInstance(); pool.setServers( servers ); pool.setFailover( true ); pool.setInitConn( 10 ); pool.setMinConn( 5 ); pool.setMaxConn( 250 ); pool.setMaintSleep( 3000 ); pool.setNagle( false ); pool.setSocketTO( 3000 ); pool.setAliveCheck( true ); pool.initialize(); } private CacheUtils() { } public static CacheUtils getInstance() { return utils; } 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 Object get(String key) { return mcc.get(key); } } |
标签:
原文地址:http://my.oschina.net/u/1453451/blog/478613