我一直在尝试使用Elasticsearch作为Memcached的替代品。我已经安装了memcached传输,它看起来很好,并且在正确的端口上。但是,如果我尝试使用java spy.memcahed客户端库,我将无法缓存内容。
相反,我得到的错误如下:
2014-10-01 08:22:31.579 INFO net.spy.memcached.MemcachedConnection: Added {QA sa=localhost/127.0.0.1:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2014-10-01 08:22:31.586 INFO net.spy.memcached.MemcachedConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@76fb509a
2014-10-01 08:22:31.679 INFO net.spy.memcached.MemcachedConnection: Reconnecting due to exception on {QA sa=localhost/127.0.0.1:11211, #Rops=2, #Wops=0, #iq=0, topRop=Cmd: 2 Opaque: 2 Key: foo Cas: 0 Exp: 1000 Flags: 0 Data Length: 3, topWop=null, toWrite=0, interested=1}
java.io.IOException: Disconnected unexpected, will reconnect.
一遍又一遍。
在Elasticsearch方面,我收到错误
[2014-10-01 08:22:31,675][ERROR][memcached.netty ] [Living Hulk] Unsupported opcode [0x2], ignoring and closing connection
这是我的客户端配置:
ConnectionFactoryBuilder factory = new ConnectionFactoryBuilder();
factory.setProtocol(ConnectionFactoryBuilder.Protocol.BINARY);
SerializingTranscoder t = new SerializingTranscoder(1000000);
t.setCompressionThreshold(1024);
factory.setTranscoder(t);
factory.setOpTimeout(1000);
factory.setTimeoutExceptionThreshold(1998);
factory.setHashAlg(DefaultHashAlgorithm.KETAMA_HASH);
factory.setLocatorType(ConnectionFactoryBuilder.Locator.CONSISTENT);
factory.setFailureMode(FailureMode.Redistribute);
factory.setUseNagleAlgorithm(false);
答案 0 :(得分:0)
事实证明这个错误是因为我打电话给#34; ADD" (0x2)在客户端上。运输目前不支持ADD。 GitHub上存在一个问题:https://github.com/elasticsearch/elasticsearch-transport-memcached/issues/7
请注意,切换到SET会修复此特定问题,但是在GET上还存在spy.memcache存在问题的其他问题。