论坛首页 入门技术论坛

memcached gzip 压缩 objectoutstream 报错

浏览 1985 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (4)
作者 正文
   发表时间:2010-03-17   最后修改:2010-03-17

memcached  在压缩数据,在get 时出现objectoutstream 报错,解决办法,关闭 memcached  压缩

 

 


public class Memcached {
 private static MemCachedClient client = new MemCachedClient(); 
 static {  
        String[] servers = {"192.168.0.1:11211"};  
        Integer[] weights = {new Integer(1)};  
 
        SockIOPool pool = SockIOPool.getInstance();  
        pool.setServers( servers );  
        pool.setWeights( weights );  
  pool.setHashingAlg(SockIOPool.NEW_COMPAT_HASH);
        pool.initialize();  
        client.setCompressEnable(false);
    }
 
 public static Object get(String key) {
  return client.get(key);
 }

 public static boolean set(String key, Object value) {
  if (value == null)
   return false;
  return client.set(key, value);
 }

 public static boolean remove(String key) {
  return client.delete(key);
 }

 public static boolean set(String key, Object value, java.util.Date expire) {
  if (value == null)
   return false;
  return client.set(key, value, expire);
 }
 
 public static boolean set(String key, Object value, int calendar,int time) {
  if (value == null)
   return false;
  
  Calendar expire = Calendar.getInstance();
  expire.add(calendar, time);
  return client.set(key, value, expire.getTime());
 }
}

论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics