Redis don't support HSET only if key exist. http://redis.io/commands#hash What will be the best way to achieve that functionality in client ?
It's easy to implement it on the client side using transaction.
WATCH hkey
isKeyExists = EXISTS hkey
if isKeyExists
MULTI
HSET hkey field value
EXEC
else
UNWATCH
When the hkey is removed after WATCH, the transaction will fail.
You can also use the scripting that was introduced in the Redis 2.6.
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