zoukankan      html  css  js  c++  java
  • Redis初探

    spring 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:context="http://www.springframework.org/schema/context"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:p="http://www.springframework.org/schema/p"
        xmlns:cache="http://www.springframework.org/schema/cache"
        xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/aop 
        http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-4.0.xsd
        http://www.springframework.org/schema/cache 
        http://www.springframework.org/schema/cache/spring-cache-4.2.xsd  
        ">
        <cache:annotation-driven /> 
        
        <bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">  
            <property name="maxIdle" value="${redis.maxIdle}" />  
            <property name="maxWaitMillis" value="${redis.maxWait}" />
            <property name="testOnBorrow" value="${redis.testOnBorrow}" />
        </bean>
         <bean id="connectionFactory"  class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">  
           <property name="poolConfig" ref="poolConfig" />  
           <property name="port" value="${redis.master.port}" />  
           <property name="hostName" value="${redis.master.host}" /> 
           <property name="password" value="${redis.master.password}" /> 
            <property name="database" value="${redis.default.db}"></property>   
       </bean>  
    
     
      <bean id="redisConnectionTimeoutAspect" class="com.paic.p2pp_ir.common.RedisConnectionTimeoutAspect" />
        <aop:config  proxy-target-class="true"   > <!-- 以类的方式申明代理,因为redisTemplate是一个类 -->
            <aop:aspect  ref="redisConnectionTimeoutAspect" >
                <aop:pointcut id="redisPointCut" expression="execution(public * org.springframework.data.redis.core.RedisTemplate.execute(..))" />
                <aop:around method="around" pointcut-ref="redisPointCut"/>
            </aop:aspect>
        </aop:config>
     
     
    
        <bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">  
           <property name="connectionFactory" ref="connectionFactory" />  
           <property name="keySerializer">  
               <bean  class="org.springframework.data.redis.serializer.StringRedisSerializer" />  
           </property>  
           <property name="valueSerializer">  
               <bean  class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" />  
           </property>  
       </bean>  
        
        <bean id="cacheManager" class="org.springframework.data.redis.cache.RedisCacheManager">  
           <constructor-arg ref="redisTemplate" />  
           <property name="defaultExpiration" value="1800"/>
           <property name="cacheNames">
            <bean   class="java.util.ArrayList">
                    <constructor-arg index="0">
                         <list>
                              <value>ir_cache</value>
                         </list>
                    </constructor-arg>
                </bean>
           </property>
       </bean>  
    </beans>
  • 相关阅读:
    用人之道(一) 如何组建软件开发队伍[转]
    用人之道(二) 何管理软件开发团队[转]
    2005年度世界500强公司名单[转]
    人类的15个欲望与游戏设计[转&收藏]
    Flash读取Cookie[转]
    高效程序员应该养成的七个习惯
    六度隔离学说,1967年,哈佛大学,Stanley Milgram
    做技术,切不可沉湎于技术[转&收藏]
    庆祝VSX团队成立,加入VSX团队申请帖
    如何把菜单添加到另外一个VSPackage的菜单里?
  • 原文地址:https://www.cnblogs.com/shibazizhan/p/7520307.html
Copyright © 2011-2022 走看看