Reputation: 1590
I am using below code to set and get value from Memcached java using MemCachedClient...
SockIOPool sockIOPool = SockIOPool.getInstance();
sockIOPool.setServers("array of server urls");
sockIOPool.setHashingAlg(CONSISTENT_HASH);
sockIOPool.initialize();
MemCachedClient memCachedClient = new MemCachedClient();
boolean set = memCachedClient.set("id.123546", 123456);
System.out.println(set);
Object value = memCachedClient.get("id.123456");
System.out.println(value);
In above code set value returns true but when I get value is giving null.
I am using below maven dependency
<dependency>
<groupId>com.whalin</groupId>
<artifactId>Memcached-Java-Client</artifactId>
<version>3.0.2</version>
</dependency>
What am I missing here ? Thanks in advance.
Upvotes: 2
Views: 883
Reputation: 6577
The keys are not the same, you have a typo:
memCachedClient.get("id.123456");
uses a different key than
memCachedClient.set("id.123546", 123456);
the 4 and 5 are swapped in set().
Upvotes: 1