SET command in redis

SET key value

Set key to hold the string value.

If the key already holds a value, it is overwritten, regardless of its type. Any previous time to live associated with the key is discarded on the successful SET operation.

TIME COMPLEXITY: O(1)

Options

EX seconds -- Set the specified expiration time, in seconds.

PX milliseconds -- Set the specified expiration time, in milliseconds.

NX -- Only set the key if it does not already exist.

XX -- Only set the key if it already exists.

RETURN VALUE: Status code reply: OK if SET was executed correctly. 

Syntax:

SET key value

Example

redis:6379> SET redisKey hello
"OK"

Output

OK


No comments:

Post a Comment