English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Redis GET Command

Redis Strings (string)

The Redis GET command is used to retrieve the value of a specified key. If the key does not exist, nil is returned. If the value stored in the key is not a string type, an error is returned.

Syntax

The basic syntax of the Redis GET command is as follows:

redis 127.0.0.1:6379> GET KEY_NAME

Available Version

>= 1.0.0

Return Value

Returns the value of the key, or nil if the key does not exist. If the key is not a string type, an error is returned.

Online Examples

# GET against a non-existent key or a string-type key
redis> GET db
(nil)
redis> SET db redis
OK
redis> GET db
"redis"
# GET against a key that is not a string
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 (string)