首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Kestrel行列使用示例

2013-04-02 
Kestrel队列使用示例package com.wujintao.kestrelimport java.io.IOExceptionimport java.util.concurr

Kestrel队列使用示例
package com.wujintao.kestrel;import java.io.IOException;import java.util.concurrent.TimeoutException;import org.junit.BeforeClass;import org.junit.Test;import net.rubyeye.xmemcached.MemcachedClient;import net.rubyeye.xmemcached.MemcachedClientBuilder;import net.rubyeye.xmemcached.XMemcachedClientBuilder;import net.rubyeye.xmemcached.command.KestrelCommandFactory;import net.rubyeye.xmemcached.exception.MemcachedException;import net.rubyeye.xmemcached.utils.AddrUtil;public class TestCase {private static MemcachedClient memcachedClient;private String ketrelQueueName = "abc";@BeforeClasspublic static void init() {MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil.getAddresses("localhost:22133"));builder.setCommandFactory(new KestrelCommandFactory());try {memcachedClient = builder.build();} catch (IOException e) {e.printStackTrace();}memcachedClient.setOptimizeGet(false);memcachedClient.setConnectTimeout(60000);}@Testpublic void testPutValue() throws TimeoutException, InterruptedException, MemcachedException{boolean flag = memcachedClient.set(ketrelQueueName, 0, "1:111");System.out.println(flag);}@Testpublic void testGetValue() throws TimeoutException, InterruptedException, MemcachedException{Object str = memcachedClient.get(ketrelQueueName);System.out.println(str);}}

?

热点排行