Memcached gets方法报错
publicstaticvoidmain(String[]args)throwsException{MemcachedClientBuilderbuilder=newXM...
public static void main(String[] args) throws Exception {
MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil.getAddresses("127.0.0.1:11211"));
client = builder.build();
client.set("numberss", 1800, 1);
client.gets("numberss");
Caused by: net.rubyeye.xmemcached.exception.UnknownCommandException: Response error,error message:Unknow command GETS_ONE,key=numberss 展开
MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil.getAddresses("127.0.0.1:11211"));
client = builder.build();
client.set("numberss", 1800, 1);
client.gets("numberss");
Caused by: net.rubyeye.xmemcached.exception.UnknownCommandException: Response error,error message:Unknow command GETS_ONE,key=numberss 展开
1个回答
展开全部
您好,
Memcached 的 gets 命令用于获取cas令牌值。如果该键在 memcached 中不存在,那么它没有返回值。
语法
memcached的基本gets命令的语法如下:
gets key
示例
set yiibai 0 900 9 memcached STORED gets yiibai VALUE yiibai 0 9 1 memcached END
在上面的例子中,我们已经使用 yiibai 作为键,并存储在memcached 设置900秒失效的时间。
使用Java应用获取CAS数据
若要从memcached服务器取cas数据,需要使用memcached的gets获取。
示例
import net.spy.memcached.MemcachedClient; public class MemcachedJava { public static void main(String[] args) { //Connecting to Memcached server on localhost MemcachedClient mcc = new MemcachedClient(new InetSocketAddress("127.0.0.1", 11211)); System.out.println("Connection to server sucessfully"); System.out.println("set status:"+mcc.set("yiibai", 900, "memcached").done); //Get value from cache System.out.println("Get from Cache:"+mcc.gets("yiibai")); } }
输出
当上述程序编译和运行,它提供了以下的输出:
Connection to server successfully set status:true Get from Cache:{CasValue 2/memcached}
Memcached 的 gets 命令用于获取cas令牌值。如果该键在 memcached 中不存在,那么它没有返回值。
语法
memcached的基本gets命令的语法如下:
gets key
示例
set yiibai 0 900 9 memcached STORED gets yiibai VALUE yiibai 0 9 1 memcached END
在上面的例子中,我们已经使用 yiibai 作为键,并存储在memcached 设置900秒失效的时间。
使用Java应用获取CAS数据
若要从memcached服务器取cas数据,需要使用memcached的gets获取。
示例
import net.spy.memcached.MemcachedClient; public class MemcachedJava { public static void main(String[] args) { //Connecting to Memcached server on localhost MemcachedClient mcc = new MemcachedClient(new InetSocketAddress("127.0.0.1", 11211)); System.out.println("Connection to server sucessfully"); System.out.println("set status:"+mcc.set("yiibai", 900, "memcached").done); //Get value from cache System.out.println("Get from Cache:"+mcc.gets("yiibai")); } }
输出
当上述程序编译和运行,它提供了以下的输出:
Connection to server successfully set status:true Get from Cache:{CasValue 2/memcached}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询