Redis Get Command
The Redis Get command is used to get the value of the specified key. If the key does not exist, nil is returned. If the value stored at 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 Versions
>= 1.0.0
Return Value
Returns the value of the key. If the key does not exist, nil is returned. If the key is not a string type, an error is returned.
Example
# 对不存在的 key 或字符串类型 key 进行 GET redis> GET db (nil) redis> SET db redis OK redis> GET db "redis" # 对不是字符串类型的 key 进行 GET 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 valueOther Extensions
Redis String