`
assen
  • 浏览: 62225 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

xmemcached net.rubyeye.xmemcached.exception.UnknownCommandException

阅读更多
memcached是一个高性能分布式缓存系统,java一般通过xmemcached客户端实现与服务器端的数据交互,下面看一个奇怪的问题,代码如下:
]
public static void main(String[] args) throws IOException {
		MemcachedClientBuilder builder = new XMemcachedClientBuilder(
				AddrUtil.getAddresses("192.168.172.39:11211"));
		MemcachedClient client = builder.build();
		try {
			client.set("hello", 0, 1);
			System.out.println("获取设置的内容 = "+client.get("hello"));
			GetsResponse<Integer> result = client.gets("hello");
			long cas = result.getCas(); //获取当前cas
			System.out.println("当前cas = "+cas);
			//尝试更新hello成2
			if (!client.cas("hello", 0, 2, cas)){
				System.err.println("cas error");
			} 
		} catch (TimeoutException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			e.printStackTrace();
		} catch (MemcachedException e) {
			e.printStackTrace();
		}
	}


最开始我的是memecached1.2.1,xmemcached2.0.0。运行main方法后报错,如下:
net.rubyeye.xmemcached.exception.MemcachedException: net.rubyeye.xmemcached.exception.UnknownCommandException: Response error,error message:Unknow command GETS_ONE,key=hello
	at net.rubyeye.xmemcached.XMemcachedClient.checkException(XMemcachedClient.java:1921)
	at net.rubyeye.xmemcached.XMemcachedClient.fetch0(XMemcachedClient.java:646)
	at net.rubyeye.xmemcached.XMemcachedClient.get0(XMemcachedClient.java:1058)
	at net.rubyeye.xmemcached.XMemcachedClient.gets(XMemcachedClient.java:1071)
	at net.rubyeye.xmemcached.XMemcachedClient.gets(XMemcachedClient.java:1093)
	at net.rubyeye.xmemcached.XMemcachedClient.gets(XMemcachedClient.java:1082)
	at com.zl.cache.city.CaseTest.main(CaseTest.java:22)
Caused by: net.rubyeye.xmemcached.exception.UnknownCommandException: Response error,error message:Unknow command GETS_ONE,key=hello
	at net.rubyeye.xmemcached.command.Command.decodeError(Command.java:251)
	at net.rubyeye.xmemcached.command.Command.decodeError(Command.java:279)
	at net.rubyeye.xmemcached.command.text.TextGetCommand.decode(TextGetCommand.java:127)
	at net.rubyeye.xmemcached.codec.MemcachedDecoder.decode0(MemcachedDecoder.java:61)
	at net.rubyeye.xmemcached.codec.MemcachedDecoder.decode(MemcachedDecoder.java:56)
	at com.google.code.yanf4j.nio.impl.NioTCPSession.decode(NioTCPSession.java:297)
	at com.google.code.yanf4j.nio.impl.NioTCPSession.decodeAndDispatch(NioTCPSession.java:237)
	at com.google.code.yanf4j.nio.impl.NioTCPSession.readFromBuffer(NioTCPSession.java:207)
	at com.google.code.yanf4j.nio.impl.AbstractNioSession.onRead(AbstractNioSession.java:196)
	at com.google.code.yanf4j.nio.impl.AbstractNioSession.onEvent(AbstractNioSession.java:341)
	at com.google.code.yanf4j.nio.impl.SocketChannelController.dispatchReadEvent(SocketChannelController.java:56)
	at com.google.code.yanf4j.nio.impl.NioController.onRead(NioController.java:157)
	at com.google.code.yanf4j.nio.impl.Reactor.dispatchEvent(Reactor.java:323)
	at com.google.code.yanf4j.nio.impl.Reactor.run(Reactor.java:180)


错误的意思就是说 gets()方法调用是 无效的命令。如是网上查了一大堆就是没有解释这个错误是如何产生的,也没有说如何解决,可能是我搜索的方法不对,这个问题卡了好久,后来实在想不到就找了另外一台装有memcached的测试机测试,一下子通过了,如是把自己本机的memcached卸载掉重新把测试机上的版本拿过来装一遍,之后在测试也通过的,最后的问题症结在于:当xmemcached版本是比较新的时候,memecached的版本也必须升级,必须是在memecached1.2.1以上的版本,新版的xmemcached在实现上有所改动,目前本地上我的是memecached1.4.4-14,xmemcached2.0.0
分享到:
评论

相关推荐

    xmemcached-1.2.6.2

    xmemcached-1.2.6.2

    xmemcached-1.2.5.jar

    还在为找不到jar文件烦心吗,不用了到我空间来有你想要的,持续更新。。。 xmemcached-1.2.5.jar

    Xmemcached用户指南

    ### Xmemcached用户指南知识点详解 #### 一、XMemcached简介 XMemcached是一款针对Java平台设计的高性能Memcached客户端。Memcached是一种分布式内存对象缓存系统,主要用于减轻数据库负担,提高动态Web应用程序的...

    Xmemcached memcached 实例

    类包括Xmemcached客户端实现和builder实现以及memcached client for java实现,对初学者有借鉴作用,特别是在开发简单例子时出现的超时情况的可以看看是否是同本事例相同。 xmemcached time out 5000 1000

    spring-xmemcached

    class="net.rubyeye.xmemcached.utils.XMemcachedClientFactoryBean" destroy-method="shutdown"&gt; ${XMemcached_servers} &lt;!-- server's weights --&gt; &lt;property name="weights"&gt; &lt;list&gt; ...

    xmemcached 2.4.6.rar

    《深入解析xmemcached 2.4.6:构建高效分布式缓存系统》 xmemcached是Java领域中一个高效、稳定且易于使用的Memcached客户端库,它为开发者提供了便捷的接口来操作Memcached服务器。在2.4.6这个版本中,xmemcached...

    xmemcached-1.4.3.jar

    xmemcached-1.4.3.jar

    xmemcache与SPRING整合

    &lt;bean name="memcachedClient" class="net.rubyeye.xmemcached.utils.XMemcachedClientFactoryBean"&gt; &lt;value&gt;host1:port1 host2:port2 ``` 这会在Spring容器中创建一个名为`memcachedClient`的bean,连接到...

    xmemcached.chm文档

    xmemcached.chm帮助文档

    Xmemcached一个java实现的分布式缓存

    import net.rubyeye.xmemcached.XMemcachedClientBuilder; public class XmemcachedExample { public static void main(String[] args) { // 创建客户端构建器 XMemcachedClientBuilder builder = new ...

    xmemcached.jar

    xmemcached使用的jar,需要的可以下载

    xmemcached 中文开发手册

    import com.googlecode.xmemcached.impl.XMemcachedClientBuilderConfigurationImpl; public class XMemcachedExample { public static void main(String[] args) { try { // 创建XMemcached客户端配置 ...

    Xmemcached用户指南.docx

    【XMemcached用户指南】 XMemcached是一款专为Java开发者设计的高效、强大的Memcached客户端。Memcached是一种高性能的分布式内存对象缓存系统,常用于缓解数据库负载,它使用简单的key-value存储方式,并通过...

    Xmemcached用户指南.pdf

    【Xmemcached用户指南】 XMemcached是一款专为Java设计的高效、全面的Memcached客户端。Memcached是一款高性能的分布式内存对象缓存系统,常用于缓解数据库负载,它通过简单的key-value存储方式来缓存数据。...

    Java的开源高性能memcached客户端XMemcached.zip

    Xmemcached是基于java nio实现的高性能可扩展的memcached客户端。它的主要特点: 高性能,稳定可靠,已经在众多公司的众多项目里得到应用。 功能完备:客户端分布式、权重、最新最完整的协议支持。 ...

    xmemcached jar包,源文件,api

    **xmemcached:高效、强大的Memcached客户端** xmemcached是一个高性能、易用且功能丰富的Java Memcached客户端库。它提供了全面的API,使得开发者能够方便地与Memcached缓存系统进行交互,从而提高Web应用的性能和...

    xmemcached-2.0.0

    xmemcached最新版本2.0.0.0

    demo_memcache_ieda

    import net.rubyeye.xmemcached.XMemcachedClientBuilder; public class XMemcachedClient { public static void main(String[] args) { MemcachedClient client = new XMemcachedClientBuilder(AddrUtil....

    xmemcached-1.2.4源码

    xmemcached-1.2.4的官方源码。 xmemcached XMemcached is a high performance, easy to use blocking multithreaded memcached client in java. It's nio based (using my opensource nio framework :yanf4j), ...

Global site tag (gtag.js) - Google Analytics