redis 与 spring整合 redisTemplate存取问题

懒懒程序员 2015-07-17 09:27:14
redisTemplate.opsForValue().set(categoryIdString, getCategoryName);
redisTemplate.opsForValue().get(categoryIdString);
像这样上一句存 下一句取的时候报null
...全文
13990 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
懒懒程序员 2015-07-17
  • 打赏
  • 举报
回复
引用 3 楼 nickycheng 的回复:
不是, 类似 public StringRedisTemplate redisTemplate() { StringRedisTemplate template = new StringRedisTemplate(redisConnectionFactory()); // explicitly enable transaction support template.setEnableTransactionSupport(true); return template; } 如果是在spring xml里配的bean,自己找下。
<bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate" p:enable-transaction-support="false" p:connection-factory-ref="connectionFactory"> </bean> 大神找到了,谢谢
nickycheng 2015-07-17
  • 打赏
  • 举报
回复
不是, 类似 public StringRedisTemplate redisTemplate() { StringRedisTemplate template = new StringRedisTemplate(redisConnectionFactory()); // explicitly enable transaction support template.setEnableTransactionSupport(true); return template; } 如果是在spring xml里配的bean,自己找下。
懒懒程序员 2015-07-17
  • 打赏
  • 举报
回复
引用 1 楼 nickycheng 的回复:
应该是你的redisTemplate设置setEnableTransactionSupport(true)了,当前线程会强制先 MULTI命令。
<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="maxIdle" value="6"></property> <property name="minEvictableIdleTimeMillis" value="300000"></property> <property name="numTestsPerEvictionRun" value="-1"></property> <property name="timeBetweenEvictionRunsMillis" value="60000"></property> </bean> 这里配置吗?
nickycheng 2015-07-17
  • 打赏
  • 举报
回复
应该是你的redisTemplate设置setEnableTransactionSupport(true)了,当前线程会强制先 MULTI命令。
懒懒程序员 2015-07-17
  • 打赏
  • 举报
回复
引用 4 楼 zhangjinhu567 的回复:
[quote=引用 3 楼 nickycheng 的回复:] 不是, 类似 public StringRedisTemplate redisTemplate() { StringRedisTemplate template = new StringRedisTemplate(redisConnectionFactory()); // explicitly enable transaction support template.setEnableTransactionSupport(true); return template; } 如果是在spring xml里配的bean,自己找下。
<bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate" p:enable-transaction-support="false" p:connection-factory-ref="connectionFactory"> </bean> 大神找到了,谢谢[/quote] 大神,我想再问个问题,就是list型 由key能不能判断value的值是分存在,因为要做分页好像只能用list但又不想有重复值

67,549

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧