Redis Get command
The Redis Get command is used to get the value of a specified key. If the key does not exist, returns nil. If the value stored in the key is not of 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 key. If the key does not exist, returns nil. If key is not of string type, an error is returned.
Example
# GET for non-existent or string-type keys
redis> GET db
(nil)
redis> SET db redis
OK
redis> GET db
"redis"
# GET key that is not a 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 string