Commands

  • All data is accessible via String keys

  • Commands are atomic

Basic Commands

Sets value.

SET key value

Returns value.

GET key

Removes a value.

DEL key

Returns value and then updates the key with a new value.

GETSET key value

Set value if it does not exist.

SETNX key value

There are other commands that work for multiple values. They have M prefix. Just DEL works for multiple by default.

MSET
MGET
MSETNX
DEL

Expiration Commands

Expires key after given number of seconds.

Expire at given time.

Set value with a timestamp in a single statement.

Get expiration date.

Remove expiration time and keep the key persistent.

Other Commands

Increase value without retrieving it first. Good for counters.

Get part of a large string.

Last updated

Was this helpful?