Spring集成spymemcached



Spring集成spymemcached

Memcached的安装部署我就不介绍了!
首先下载spymemcached,下载地址:
jar:https://spymemcached.googlecode.com/files/spymemcached-2.10.3.jar
javadoc:https://spymemcached.googlecode.com/files/spymemcached-2.10.3-javadoc.jar
源码:https://spymemcached.googlecode.com/files/spymemcached-2.10.3-sources.jar
Spring的配置文件:config-cache.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
    <bean id="memcachedClient" class="net.spy.memcached.spring.MemcachedClientFactoryBean">
        <property name="servers" value="#{configproperties['memcached.server.url']}" />
        <property name="protocol" value="BINARY" />
        <property name="transcoder">
            <bean class="net.spy.memcached.transcoders.SerializingTranscoder">
                <property name="compressionThreshold" value="1024" />
            </bean>
        </property>
        <property name="opTimeout" value="1000" />
        <property name="timeoutExceptionThreshold" value="2000" />
        <!-- 这是一个坑:<property name="hashAlg" value="KETAMA_HASH"/>-->
        <property name="hashAlg">
            <value type="net.spy.memcached.DefaultHashAlgorithm">KETAMA_HASH</value>
        </property>
        <property name="locatorType" value="CONSISTENT" />
        <property name="failureMode" value="Redistribute" />
        <property name="useNagleAlgorithm" value="false" />
    </bean>
</beans>

Spring的配置文件:config-service.xml

1
2
3
<bean class="com.digitalchina.security.interceptor.ToKenCheckInterceptor" >
                    <property name="memcachedClient" ref="memcachedClient" />
                </bean>

Spring的源码:

1
2
3
4
5
6
7
8
9
10
11
12
@Component
public class ToKenCheckInterceptor extends AbstractWebServiceInterceptor implements InitializingBean {
    public static final String CSP_USER_SECURITY_CONTEXT_KEY = "CSP_USER_SECURITY_CONTEXT_KEY";
    public static final int HTTP_STATUS_INSUFFICIENT_USER_LEVEL = 431;
    @Autowired
    private MemcachedClient memcachedClient;
       
       
    public void setMemcachedClient(MemcachedClient memcachedClient) {
        this.memcachedClient = memcachedClient;
    }
    。。。  。。。



本文转自 梦朝思夕 51CTO博客,原文链接:

http://blog.51cto.com/qiangmzsx/1413649

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值