Search code examples
databaseredisdatastore

what is purpose of command smove in redis?


in redis for moving on set collection to the another set collection we can use "smove" command as

bellow :

smove set1 set2 member

and my question is this operation , solve what`s problem . if someone has good answer , tell me please


Solution

  • Without this command you would have to remove and item from set1 and add it to set2.

    This is not atomic.

    If your process died in the middle you would lose that set entry before it was added to set2

    https://redis.io/commands/smove has more information