GET
GET key
- Group
- String
- Complexity
- O(1)
- Arity
- 2 (exactly, counting the command name)
- Flags
- read-only, fast
- Keys
- first 1, last 1, step 1
- HotKV Cloud
- All plans
- On-Premise
- no license needed
GET returns the string stored at key. Integers stored with
SET or INCR come back as their decimal
text. A missing key is not an error: the reply is nil.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| The key holds a string | Bulk string | Bulk string |
| The key does not exist | Nil bulk string | Null |
GET replies with a WRONGTYPE error when the key holds a value that is not a
string.
Examples
Section titled “Examples”127.0.0.1:6379> SET greeting "hello"OK127.0.0.1:6379> GET greeting"hello"127.0.0.1:6379> GET missing(nil)127.0.0.1:6379> RPUSH queue job1(integer) 1127.0.0.1:6379> GET queue(error) WRONGTYPE Operation against a key holding the wrong kind of valueCompatibility
Section titled “Compatibility”Same as Redis 7 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.