Upstash Documentation

SET

Set a key to hold a string value.
1 min read

Arguments#

keystringrequired#

The key

valueTValuerequired#

The value, if this is not a string, we will use JSON.stringify to convert it to a string.

optsobject#

You can pass a few options to the command.

Show properties
getboolean#

Instead of returning "OK", this will cause the command to return the old value stored at key, or null when key did not exist.

exinteger#

Adds an expiration (in seconds) to the key.

pxinteger#

Adds an expiration (in milliseconds) to the key.

exatinteger#

Expires the key after the given timestamp (in seconds).

pxatinteger#

Expires the key after the given timestamp (in milliseconds).

keepTtlboolean#

Keeps the old expiration if the key already exists.

nxboolean#

Only set the key if it does not already exist.

xxboolean#

Only set the key if it already exists.

Response#