redis SMOVE command


  Translation results:

move

UK[mu:v] 美[muv]

vt.& vi. move, move

vi.action ; move; progress; (machine, etc.) start

vt. propose; move; shake; change

n. change; migrate

Third person singular: moves plural: moves Present participle: moving Past tense: moved Past participle: moved

redis SMOVE commandsyntax

Function: Move the member element from the source collection to the destination collection.

Syntax: SMOVE source destination member

Explanation: SMOVE is an atomic operation. If the source collection does not exist or does not contain the specified member element, the SMOVE command does nothing and simply returns 0 . Otherwise, the member element is removed from the source collection and added to the destination collection. When the destination collection already contains a member element, the SMOVE command simply deletes the member element from the source collection. When source or destination is not a collection type, an error is returned.

Available versions: >= 1.0.0

Time complexity: O(1)

Return: If the member element is successfully removed, return 1. If the member element is not a member of the source collection and no operations are performed on the destination collection, then 0 is returned.

redis SMOVE commandexample

redis> SMEMBERS songs
1) "Billie Jean"
2) "Believe Me"
redis> SMEMBERS my_songs
(empty list or set)
redis> SMOVE songs my_songs "Believe Me"
(integer) 1
redis> SMEMBERS songs
1) "Billie Jean"
redis> SMEMBERS my_songs
1) "Believe Me"

Home

Videos

Q&A