![](/img/trans.png)
[英]Where can close a Lettuce Redis connection in my Spring Boot application?
[英]Redis TTL is always -1 and can't be configured in a Spring Boot application
我無法為bucket4j配置配置 TTL。 它總是-1。 這與奇怪的密鑰序列化有關嗎,看截圖? TTL 配置確實適用於其他但不適用於 bucket4j。
@Bean
fun redisCacheManagerBuilderCustomizer(): RedisCacheManagerBuilderCustomizer {
return RedisCacheManagerBuilderCustomizer { builder ->
builder
.withCacheConfiguration(
"bucket4j",
RedisCacheConfiguration
.defaultCacheConfig()
.disableCachingNullValues()
.entryTtl(Duration.of(100, ChronoUnit.SECONDS))
)
.withCacheConfiguration(
"other",
RedisCacheConfiguration
.defaultCacheConfig()
.disableCachingNullValues()
.entryTtl(Duration.of(100, ChronoUnit.SECONDS))
)
}
}
應用程序屬性:
spring.redis.database=0
spring.redis.host=localhost
spring.redis.port=16379
spring.redis.password=mypass
spring.redis.timeout=60000
spring.cache.cache-names=other,bucket4j
您可以嘗試配置: spring.cache.redis.time-to-live
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.