码迷,mamicode.com
首页 > 编程语言 > 详细

Spring集成spymemcached

时间:2014-05-20 21:59:40      阅读:415      评论:0      收藏:0      [点我收藏+]

标签:spring集成   spymemcached   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

<?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

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

Spring的源码:

@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;
    }
    。。。  。。。






本文出自 “梦朝思夕” 博客,请务必保留此出处http://qiangmzsx.blog.51cto.com/2052549/1413649

Spring集成spymemcached,布布扣,bubuko.com

Spring集成spymemcached

标签:spring集成   spymemcached   spring spymemcached   

原文地址:http://qiangmzsx.blog.51cto.com/2052549/1413649

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!