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>
  • 相关阅读:
    GeoServer 2.2 正式版发布,GIS 服务器
    Spring Shell 1.0.0.RC1 发布
    微软发布支持Windows Desktop和F#的Visual Studio Express版本
    XINS 3.0 正式版发布,远程 API 调用规范
    YUI 3.7.2 补丁版发布
    HTML5 Boilerplate 4:改进了Apache配置和图片替换技术,并采用MIT许可证
    解决Windows Phone平台上不能枚举工程自带资源的问题
    截短 UTF8 字符串
    Spring Data Neo4j 2.1.0 RC4 发布
    GTK+ 3.5.18 发布,GUI 开发工具包
  • 原文地址:https://www.cnblogs.com/shibazizhan/p/7520307.html
Copyright © 2011-2022 走看看