Reputation: 2175
How can you check if a key exists and get its value if it does?
I am concerned with concurrency problems. Fox example
EXISTS foo
followed by
GET foo
There will be a problem if the key is deleted between EXISTS
and GET
. How should you deal with this?
Upvotes: 0
Views: 2479
Reputation: 583
Only GET method is sufficient in your use case. Doing a GET on any key returns the Value of that key if the key is set, otherwise it simply returns a (nil)
.
Upvotes: 1