新增redis
This commit is contained in:
@@ -123,4 +123,50 @@
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- =================配置Redis================= -->
|
||||
<!-- Redis连接池配置 -->
|
||||
<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
|
||||
<property name="maxTotal" value="100"/>
|
||||
<property name="maxIdle" value="20"/>
|
||||
<property name="maxWaitMillis" value="10000"/>
|
||||
<property name="testOnBorrow" value="true"/>
|
||||
</bean>
|
||||
|
||||
<!-- Redis连接工厂 -->
|
||||
<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
|
||||
<property name="hostName" value="localhost"/>
|
||||
<property name="port" value="6379"/>
|
||||
<property name="password" value=""/>
|
||||
<property name="database" value="0"/>
|
||||
<property name="poolConfig" ref="jedisPoolConfig"/>
|
||||
</bean>
|
||||
|
||||
<!-- Redis模板 -->
|
||||
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
|
||||
<property name="connectionFactory" ref="jedisConnectionFactory"/>
|
||||
<property name="keySerializer">
|
||||
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
|
||||
</property>
|
||||
<property name="valueSerializer">
|
||||
<bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer"/>
|
||||
</property>
|
||||
<property name="hashKeySerializer">
|
||||
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
|
||||
</property>
|
||||
<property name="hashValueSerializer">
|
||||
<bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- StringRedisTemplate(可选,用于String类型操作) -->
|
||||
<bean id="stringRedisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
|
||||
<property name="connectionFactory" ref="jedisConnectionFactory"/>
|
||||
</bean>
|
||||
|
||||
<!-- Redis缓存管理器 -->
|
||||
<bean id="redisCacheManager" class="org.springframework.data.redis.cache.RedisCacheManager">
|
||||
<constructor-arg name="redisOperations" ref="redisTemplate"/>
|
||||
<property name="defaultExpiration" value="3600"/>
|
||||
</bean>
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user