In Jedis, I want to set some key and value with expiring time by a single invocation.
I can do this by combination of set() and expire() but it needs two invocations.
I found the following method:
set(final String key, final String value, final String nxxx, final String expx, final long time)
But I have to choose nx (Only set the key if it does not already exist.) or xx (Only set the key if it already exist.).
I want to cover both cases.
Any suggestion? Or any reason to be written like this?
Redis has a SETEX command, which sets the key with an expiry.
jedis.setex(key, expireAfter, value);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With