killme2008 / xmemcached

High performance, easy to use multithreaded memcached client in java.
http://fnil.net/xmemcached
Apache License 2.0
757 stars 281 forks source link

incrWithNoReply's behavior is not same with incr #120

Closed carryxyh closed 4 years ago

carryxyh commented 4 years ago

When I use incrWithNoReply to handle a key that does not exist in memcache, the initial value is not 0, but null. When I use incr to handle non-existent keys, the initial value is set to 0.

MemcachedClientBuilder builder = new XMemcachedClientBuilder(
        AddrUtil.getAddresses("music-test8.hz.163.org:11214"));
MemcachedClient build = builder.build();
build.incrWithNoReply("abc", 1L);

Object abc = build.get("abc");
// this will print `null`.
System.out.println(abc);

build.incr("xyh", 1L);
Object xyh = build.get("xyh");
// this will print `0`.
System.out.println(xyh);