w3resource

Redis String: Get key

Description

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

Syntax:

Basic syntax of redis GET command is shown below:

redis 127.0.0.1:6379> GET KEY_NAME

Available since

1.0.0.

Return Value

Simple string reply. Value or key or nil.

Return Value Type

String

Example

First, set a key in redis and then get it.

redis 127.0.0.1:6379> SET example redis
OK
redis 127.0.0.1:6379> GET example
"redis"

Previous: SET
Next: GETRANGE



Follow us on Facebook and Twitter for latest update.