1 Introduction
Xmemcached is a high-performance Java NIO-based memcached client. After three RC versions, the 1.10-final version is officially released.
Xmemcached Features at a glance:
1. High performance
2, support the complete memcached text protocol, the binary Protocol will be implemented in version 1.2.
3. Support JMX, can adjust performance parameters through Mbean, dynamically add/Remove server, view statistics, etc.
4, support client statistics
5, support the dynamic increase or decrease of memcached node.
6, support memcached distribution: Remainder distribution and consistent hash distribution.
7. More performance tuning options.
2 Integration with spring
Xmemcached from 1.1.2, it can be flexibly and conveniently integrated with the spring framework.
2.1 The simplest example
<bean name= "memcachedclient" class= "Net.rubyeye.xmemcached.utils.XMemcachedClientFactoryBean" >
<property name= "Servers" >
<value>host1:port1 host2:port2</value>
</property>
</bean>
You can then use the memcachedclient in the bean.
2.2 A little bit more complicated example
<bean name= "Memcachedclient"
class= "Net.rubyeye.xmemcached.utils.XMemcachedClientFactoryBean" >
<property name= "Servers" >
<value>host1:port1 Host2:port2 host3:port3</value>
</property>
<property name= "Weights" >
<list>
<value>1</value>
<value>2</value>
<value>3</value>
</list>
</property>
<property name= "Sessionlocator" >
<bean class= "Net.rubyeye.xmemcached.impl.KetamaMemcachedSessionLocator" ></bean>
</property>
<property name= "Transcoder" >
<bean class= "Net.rubyeye.xmemcached.transcoders.SerializingTranscoder"/>
</property>
<property name= "Bufferallocator" >
<bean class= "Net.rubyeye.xmemcached.buffer.SimpleBufferAllocator" ></bean>
</property>
</bean>
The meaning of each parameter:
Parameters |
Meaning |
Servers |
Server list, format:ip:port |
Weights |
Host mapping:host1 corresponds to number 1th, Host2 2nd . |
Sessionlocator |
Session dispensers, which have their own, affect distributed |
Transcoder |
Communication Coding Method |
Bufferallocator |
Buffer Allocator |
Note:
Default standard hash, hash (key) mod server_count (remainder distribution)
Memcachedclientbuilder builder = new Xmemcachedclientbuilder (addrutil.getaddresses ("server1:11211 server2:11211 server3:11211 ")); memcachedclient MC = Builder.build ();
Can be changed to consistent hash (consistent hash):
Memcachedclientbuilder builder = new Xmemcachedclientbuilder (addrutil.getaddresses ("server1:11211 server2:11211 server3:11211 ")); Builder.setsessionlocator (New Ketamamemcachedsessionlocator ()); memcachedclient MC = Builder.build ();
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Integrate with spring with memcached client xmemcached