ITPub博客

首页 > > > Memcache连接问题

Memcache连接问题

作者:z_paul 时间:2019-10-08 17:06:10 0 删除 编辑

我的代码是:

1         String [] servers = {"192.168.146.1:11211"};
 2         SockIOPool pool = SockIOPool.getInstance();
 3         pool.setServers(servers);
 4         pool.setFailover(true);
 5         pool.setInitConn(10);
 6         pool.setMinConn(5);
 7         pool.setMaxConn(25);
 8         pool.setMaintSleep(30);
 9         pool.setNagle(false);
10         pool.setSocketTO(3000);
11         pool.setAliveCheck(true);
12         pool.setHashingAlg(SockIOPool.CONSISTENT_HASH);
13         pool.initialize();
14         MemCachedClient memCachedClient = new MemCachedClient();
15         memCachedClient.add("key", 1);
16         boolean result = memCachedClient.set("key", 2);
17         System.out.println(result);
18         Object value = memCachedClient.get("aaa");
19         System.out.println(value);

连接的是虚拟机linux上的memcache,memcache也启动正常,运行时控制台输出:

false

null

说明我set没成功,网上找了好久找不到解决办法,哪位大神知道的帮忙看看,多谢了!

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/75/viewspace-3160197/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-07-17

  • 博文量
    151
  • 访问量
    6024