Reputation: 2687
I'm currently using Redis and doing an HGET
followed by an HDEL
to remove the field (and its value) from the hash once I've retrieved the value I need (which only needs to be used once).
Is there any way to do this in one operation (i.e. get a field and remove it from the hash)? I skimmed through the docs and couldn't find the right command.
Upvotes: 0
Views: 877
Reputation: 4332
Transactions will do this. Use the MULTI command to start a transaction, within the transaction HGET what you want, HDEL it, and then EXEC.
You could also write a Lua script to do this.
Upvotes: 2