For caching a map I want to set TTL,for now, I am doing like this
try { redisSyncCommand.hmset(key, map); redisSyncCommand.expire(key, TTL);} catch(Exception ex) { redisSyncCommand.expire(key, TTL);}
However I have a timeout of 6s from my service end, so if hmset takes more than 6s, it times out.So even in the catch block, If I expire the key.. in reality, Redis might still be hmset-ting the map and expire happens first and then hmset happens.. so it remains in the cache forever. how can I solve this?