GET
Get the value of a key.
Syntax
GET keyDescription
The GET command retrieves the string value associated with a key. If the key does not exist, GET returns nil (null bulk string).
Arguments
key(required): The name of the key to retrieve.
Return Value
Returns a Bulk String:
- The value of the key if it exists
nil(null bulk string) if the key does not exist
Examples
Getting an Existing Key
SET mykey "Hello ECHO DB"
GET mykeyResponse:
OK
"Hello ECHO DB"Getting a Non-Existent Key
GET nonexistentResponse:
(nil)Getting a Key After Deletion
SET mykey "value"
DEL mykey
GET mykeyResponse:
OK
(integer) 1
(nil)Notes
GETonly works with string values. If the key holds a list, you'll get aWRONGTYPEerror- Keys are case-sensitive
- Returns
nilif the key doesn't exist or has expired
Use Cases
- Retrieving Cached Values: Get previously stored cache entries
- Reading Configuration: Retrieve configuration values
- Session Lookup: Get session data by session ID
- Simple Data Retrieval: Basic key-value lookups