Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

How can I make redis HMSET with EXPIRE atomic with Java?

$
0
0

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?


Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>