Redis – String Setex Command

  • Post author:
  • Post category:Redis
  • Post comments:0 Comments

Redis SETEX command is used to set some string value with a specified timeout in Redis key.

Return Value

Simple string reply. OK, if the value is set in key. Null, if the value is not set.

Syntax

Following is the basic syntax of Redis SETEX command.

redis 127.0.0.1:6379> SETEX KEY_NAME TIMEOUT VALUE

Example

redis 127.0.0.1:6379> SETEX mykey 60 redis 
OK 
redis 127.0.0.1:6379> TTL mykey 
60 
redis 127.0.0.1:6379> GET mykey 
"redis 

Leave a Reply