基于Memcached的组件/客户端的用法介绍

Java客户端 xmemcached spymemcached :http://www.iteye.com/news/7717-xmemcached---faster-than-spymemcached

a) XMemcached:http://code.google.com/p/xmemcached/

需要slf4j组件的支持 :http://www.slf4j.org/

测试代码:

import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.concurrent.TimeoutException;

import net.rubyeye.xmemcached.MemcachedClient;
import net.rubyeye.xmemcached.XMemcachedClient;
import net.rubyeye.xmemcached.exception.MemcachedException;

public class XMemcache {

	public static void main(String[] args) throws IOException, TimeoutException, InterruptedException, MemcachedException {

		InetAddress addr = InetAddress.getByName("192.168.11.128");
		InetSocketAddress ia = new InetSocketAddress(addr, 11211);
		MemcachedClient client = new XMemcachedClient(ia);
		
		client.set("SX_Key", 120, "My_XMemcache_Data");
		System.out.println(client.get("SX_Key"));
		client.shutdown();
	}
}

b) SpyMemcached: http://code.google.com/p/spymemcached/

import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;

import net.spy.memcached.MemcachedClient;

public class SpyMemcached {

	public static void main(String[] args) throws IOException {
		
		InetAddress addr = InetAddress.getByName("192.168.11.128");
		InetSocketAddress ia = new InetSocketAddress(addr, 11211);
		MemcachedClient client = new MemcachedClient(ia);
		
		client.set("SM_Key", 120, "My_SpyMemcache_Data");
		System.out.println(client.get("SM_Key"));
		client.shutdown();
	}
}

Memcached CAS 协议:

http://langyu.iteye.com/blog/680052


PHP下extention:memcache vs memcached

http://us3.php.net/manual/en/book.memcache.php

http://us3.php.net/manual/en/book.memcached.php

更多资料:

http://stackoverflow.com/questions/1442411/using-memcache-vs-memcached-with-php

http://www.leonzhang.com/2011/06/24/memcached-vs-php-memcache/

http://shikii.net/blog/installing-memcached-for-php-5-3-on-windows-7/


CakePHP下的一些组件

https://github.com/salgo/cakephp-viewmemcache

https://github.com/kamisama/CakePHP-Memcached-Engine

http://andy-gale.com/cakephp-view-memcache.html


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值