Xmemcatch 初学者 第一章

  

   相关的API : http://xmemcached.googlecode.com/svn/trunk/apidocs/net/rubyeye/xmemcached/XMemcachedClientBuilder.html

   初学者指南:http://code.google.com/p/xmemcached/wiki/User_Guide_zh#使用指南

   新命令介绍: http://code.google.com/p/memcached/wiki/NewCommands

   下载地址:http://code.google.com/p/memcached/downloads/list


 在linux 下安装memcatch:

http://www.ccvita.com/257.html

http://www.2cto.com/os/201203/125164.html

http://www.cnblogs.com/sunson/archive/2012/04/07/2436086.html  (详细)


  

 MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil.getAddresses("localhost:11211"));
        MemcachedClient memcachedClient = builder.build();
        try {
            memcachedClient.set("hello", 0, "Hello,xmemcached");
            String value = memcachedClient.get("hello");
            System.out.println("hello=" + value);
            memcachedClient.delete("hello");
            value = memcachedClient.get("hello");
            System.out.println("hello=" + value);
        } catch (MemcachedException e) {
            System.err.println("MemcachedClient operation fail");
            e.printStackTrace();
        } catch (TimeoutException e) {
            System.err.println("MemcachedClient operation timeout");
            e.printStackTrace();
        } catch (InterruptedException e) {
            // ignore
        }
        try {
            //close memcached client
            memcachedClient.shutdown();
        } catch (IOException e) {
            System.err.println("Shutdown MemcachedClient fail");
            e.printStackTrace();
        }


maven配置

   <dependency>
            <groupId>com.googlecode.xmemcached</groupId>
            <artifactId>xmemcached</artifactId>
            <version>1.3.8</version>
        </dependency>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值