I'm trying to set large TTL (10+ days) for key-value on Redisson.
I noctied that Redisson convert that TTL to milliseconds and execute command on Redis(DragonFlyDB).
org.redisson.client.RedisException: ERR value is not an integer or out of range. channel: [id: 0xfa05de9e, L:/127.0.0.1:32812 - R:localhost/127.0.0.1:32773] command: (PSETEX), promise: java.util.concurrent.CompletableFuture@67330d28[Not completed], params: [hello, 864000000, PooledUnsafeDirectByteBuf(ridx: 0, widx: 8, cap: 256)]
864000000
is not larger then maximum Integer
DragonFly(https://github.com/dragonflydb/dragonfly) Is there a way to archieve this ?
override fun cacheString(key: String, value: String, ttl: Duration): RFuture<Void> {
val result = redisClient.getBucket<String>(key).setAsync(value, ttl.seconds, TimeUnit.SECONDS)
return result
}
val failResult = cacheMangerService.cacheString("hello", "world", Duration.ofDays(10)) // throw Exception
val succesResult = cacheMangerService.cacheString("hello", "world", Duration.ofDays(3)) // Successful
Edited: I switch DragonFlyDB to RedisCluster --> And 864000000 work. So it seem like it only apply to DragonFlyDB.
Solved: For some reason it only happened when set TTL in setAsync but not set TTL manually with expire(). So I workaround by change set TTL with expire()
Thanks you for reading
Workaround: For some reason it only happened when set TTL in setAsync but not set TTL manually with expire() --> expire() use a eval srcipt. So I workaround by change set TTL with expire()
val bucket = getBucket(buildKey(key))
bucket.setAsync(value).handleAsync { _, throwable ->
if (throwable != null) {
logger.error("Error in caching value: ", throwable)
} else {
bucket.expireAsync(ttl).handleAsync { rs, throwable ->
if (throwable != null || !rs) {
// If expire error then remove the value
logger.error("Error in set expire for value: ", throwable)
bucket.delete()
}
}
}
}