Expected behavior
The restore* group of functions use int as the TTL parameter, this should actually be long because the redis restore command sets the TTL as milliseconds NOT seconds.
As per the redis docs: https://redis.io/commands/restore
"If ttl is 0 the key is created without any expire, otherwise the specified expire time (in milliseconds) is set".
Actual behavior
Integer overflow when passing a large enough TTL as milliseconds
Steps to reproduce:
String key = "testkey";
int ttl = (int)TimeUnit.DAYS.toSeconds(30); // 30 days as seconds
jedis.set(key, "test-value");
jedis.expire(key, ttl);
// dump record and TTL as milliseconds
byte[] dump = jedis.dump(key);
long pttl = jedis.pttl(key);
jedis.restoreReplace(key, Math.toIntExact(pttl), dump); // results in: ArithmeticException: integer overflow
//jedis.restoreReplace(key, (int)pttl, dump); // unsafe cast results in: JedisDataException: ERR Invalid TTL value, must be >= 0
Redis / Jedis Configuration
Jedis version:
latest
Redis version:
6.0.9
Java version:
openjdk version "11.0.9.1"