GETSET command in redis

GETSET key value

GETSET is an atomic set of this value and returns the old value command. Set key to the string value and return the old value stored at key.

The string can't be longer than 1073741824 bytes (1 GB).

TIME COMPLEXITY: O(1)

RETURN VALUE: Returns the old value associated with the key in Redis.

Example 1: When the key is present

redis:6379> GETSET redisKey 100
"1000"

Output

"1000"

Example 2: When the key is pressent

redis:6379> GETSET redisk 1000
(nil)

Output

nil

No comments:

Post a Comment