setex

SETEX

SETEX key seconds value

Set key to hold the string value and set key to timeout after a given number of seconds. This command is equivalent to executing the following commands:

SET mykey value
EXPIRE mykey seconds

SETEX is atomic, and can be reproduced by using the previous two commands inside an MULTI / EXEC block- It is provided as a faster alternative to the given sequence of operations, because this operation is very common when Redis is used as a cache-

An error is returned when seconds is invalid-

Return value

Simple string reply

Examples

redis> SETEX mykey 10 "Hello" "OK" redis> TTL mykey (integer) 10 redis> GET mykey "Hello"

© 2009–2017 Salvatore Sanfilippo
Licensed under the Creative Commons Attribution-ShareAlike License 4.0.
https://redis.io/commands/setex

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部