Getting this error most of the time with memcached:
Caused by: net.spy.memcached.internal.CheckedOperationTimeoutException: Timed out waiting for operation - failing node: /127.0.0.1:11211
For this code:
private byte[] cacheGet(String key) {
try {
if(mc == null) {
ConnectionFactory factory = new ConnectionFactoryBuilder()
.setProtocol(ConnectionFactoryBuilder.Protocol.BINARY)
.setFailureMode(FailureMode.Redistribute)
.setOpTimeout(MEMCACHED_TIMEOUT) // 60 seconds
.build();
ms = new MemcachedClient(factory, AddrUtil.getAddresses(Arrays.asList(MEMCACHED_CONN, MEMCACHED_CONN_2)));
}
Object value = mc.get(key);
return (byte[]) value;
} catch (Exception e) {
e.printStackTrace();
mc.shutdown();
mc = null;
} finally {
//mc.shutdown(); // needed?
}
return null;
}
My current solution is to restart the memcached server and problem solved, everything works fine again, cache works, however is there a way to handle this gracefully such that for the next hit it would work if this is only a client error or is this a unrecoverable memcached server error?