Redisson: Use PSETEX for time to live with precision of less than second

Created on 8 Mar 2017  ·  4Comments  ·  Source: redisson/redisson

Right now only usage of SETEX is mapped.
Therefore even though the API allows setting ttl using value(long) and TimeUnit.
Using values like 1500ms gets translated into 1s, since it's using SETEX command which only takes seconds.
And using values like 700ms gets translated to 0s, which makes the command fail by being an invalid SETEX parameter ("ERR invalid expire time in setex").

Unless there is performance/memory implication i am not aware, using PSETEX for higher precision should cover that
https://redis.io/commands/psetex

All 4 comments

Quite important remark! I'll replace setex usage with psetex

Thanks @mrniko.
If so, please keep also in mind EXPIRE vs PEXPIRE
However, both commands are available only since redis 2.6.0. But i don't think that's a problem, since you already use some commands from redis 3.2 like CLIENT REPLY
https://redis.io/commands/pexpire

Yeah, I'm aware about PEXPIRE and other similar command. They already used in RedissonExpirable object

Done

Was this page helpful?
0 / 5 - 0 ratings