I am using JedisCluster, and I need to set a key with 1-hour expiry, now I am doing something like
getJedisCluster().set(key,value);
getJedisCluster().expire(key, 60 * 60);
But I hope I can using a single command to reduce the round trip to send commands
With Redis cli , I can write this:
set key value ex 3600
But in JedisCluster, I can only find a interface:
public String set(final String key, final String value, final String nxxx, final String expx, final long time) {
which means I either should use setex or setnx.
But I hope my set command applies both to update or insert.
How can I do this?
Ps: Jedis-Client's version is 2.9.0