登录 注册
当前位置:主页 > 资源下载 > 10 > memcached-2.4.2.jar memcached-2.4.2.jar下载

memcached-2.4.2.jar memcached-2.4.2.jar下载

  • 更新:2024-07-23 13:09:26
  • 大小:239KB
  • 推荐:★★★★★
  • 来源:网友上传分享
  • 类别:Memcached - 数据库
  • 格式: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); } }