新增redis

This commit is contained in:
2026-04-20 23:32:52 +08:00
parent fea143f0e1
commit 5a713e8160
13 changed files with 1689 additions and 514 deletions
+46
View File
@@ -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>