Redis 3.0.5
Spring Data Redis 1.3.6
jedis 2.6.3
- 我们的 Web 应用程序通过 pub/sub 从 redis 接收数据。
- 还以键/值对的形式在 redis 上执行读/写数据。
- 读/写发生在侦听器线程、独立监控线程和 http 请求线程上。
- 我们为 Listener 和 redis 模板使用了相同的连接工厂
- 我们的 redis 服务器配置了“timeout=30”
<bean id="jedisConnectionFactory"
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="hostName" value="nnnn"></property>
<property name="port" value="nnnn"></property>
<property name="password" value="****"></property>
</bean>
<bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
<property name="connectionFactory" ref="jedisConnectionFactory" />
</bean>
<bean id="redisContainer"
class="org.springframework.data.redis.listener.RedisMessageListenerContainer">
<property name="connectionFactory" ref="jedisConnectionFactory" />
<property name="messageListeners">
<map>
<entry key-ref="messageListener">
<bean class="org.springframework.data.redis.listener.ChannelTopic">
<constructor-arg value="topic_name" />
</bean>
</entry>
</map>
</property>
<property name="taskExecutor" ref="redisTaskExecutor" /> …Run Code Online (Sandbox Code Playgroud)