Easy Tutorial
❮ Sets Spop Strings Psetex ❯

Redis Get Command

Redis Strings

The Redis Get command is used to retrieve the value of a specified key. If the key does not exist, it returns nil. If the key stores a value that is not of string type, it returns an error.

Syntax

The basic syntax for the redis Get command is as follows:

redis 127.0.0.1:6379> GET KEY_NAME

Available Versions

= 1.0.0

Return Value

Returns the value of the key. If the key does not exist, it returns nil. If the key is not of string type, it returns an error.

Examples

# GET on a non-existent key or a string type key

redis> GET db
(nil)

redis> SET db redis
OK

redis> GET db
"redis"

# GET on a key that is not of string type

redis> DEL db
(integer) 1

redis> LPUSH db redis mongodb mysql
(integer) 3

redis> GET db
(error) ERR Operation against a key holding the wrong kind of value

Redis Strings

❮ Sets Spop Strings Psetex ❯