spring整合memcache
Xmemcached是基于javanio实现的高性能可扩展的memcached客户端。
pom.xml
<dependency> <groupId>com.googlecode.xmemcached</groupId> <artifactId>xmemcached</artifactId> </dependency>
spring配置
<bean name="memcachedClient" destroy-method="shutdown" class="net.rubyeye.xmemcached.utils.XMemcachedClientFactoryBean"> <property name="servers"> <value>${memcache.cluster}</value> </property> <property name="weights"> <list> <value>1</value> <value>2</value> </list> </property> <property name="sessionLocator"> <bean class="net.rubyeye.xmemcached.impl.KetamaMemcachedSessionLocator" /> </property> <property name="transcoder"> <bean class="net.rubyeye.xmemcached.transcoders.SerializingTranscoder" /> </property> <property name="bufferAllocator"> <bean class="net.rubyeye.xmemcached.buffer.SimpleBufferAllocator"/> </property> </bean>
具体使用
String key='demo'; String obj='123'; int second=120; MemcachedClient client=((MemcachedClient)SpringBeanUtil.getBean("memcachedClient")); client.delete(key); client.add(key, second, obj);
memcached服务安装自行参照官网相关文档
相关推荐
yupi0 2020-10-10
spring 2020-08-18
编程点滴 2020-07-29
幸运小侯子 2020-07-05
itjavashuai 2020-07-04
qingjiuquan 2020-06-29
shushan 2020-06-25
小鱿鱼 2020-06-22
咻pur慢 2020-06-18
melonjj 2020-06-17
qingjiuquan 2020-06-13
neweastsun 2020-06-05
小鱿鱼 2020-06-05
mxcsdn 2020-05-31
吾日五省我身 2020-05-27
牧场SZShepherd 2020-05-27
sweetgirl0 2020-05-14