PSETEX · Valkey

PSETEX

Sets both string value and expiration time in milliseconds of a key. The key is created if it doesn’t exist.

Usage

PSETEX key milliseconds value

Description

PSETEX works exactly like SETEX with the sole difference that the expire time is specified in milliseconds instead of seconds.

Reply

Simple string reply: OK.

Complexity

O(1)

ACL Categories

@slow @string @write

Examples

127.0.0.1:6379> PSETEX mykey 1000 "Hello"
OK
127.0.0.1:6379> PTTL mykey
(integer) 990
127.0.0.1:6379> GET mykey
"Hello"

History

See also

APPEND, DECR, DECRBY, GET, GETDEL, GETEX, GETRANGE, INCR, INCRBY, INCRBYFLOAT, LCS, MGET, MSET, MSETNX, SET, SETRANGE, STRLEN.