spring-data-redis 使用
生活随笔
收集整理的這篇文章主要介紹了
spring-data-redis 使用
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
以前使用過Jedis,后面因項目需要使用spring-data-redis,設(shè)置一個鍵值及其過期時間后怎么都不對。
源代碼:
redisTemplate.opsForValue().set(key, value,100l);于是,不得不翻出api:
Overwrite parts of key starting at the specified offset with given value.
才發(fā)現(xiàn)第三個參數(shù)不是timeout,而是offset。
正確的代碼應(yīng)該是:
redisTemplate.opsForValue().set(key, value,timeout,TimeUnit.SECONDS);?
轉(zhuǎn)載于:https://www.cnblogs.com/davidwang456/p/4818783.html
總結(jié)
以上是生活随笔為你收集整理的spring-data-redis 使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Solr实现SQL的查询与统计--转载
- 下一篇: 接口设计备忘录