Echo DB

GET

Get the value of a key.

Syntax

GET key

Description

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 mykey

Response:

OK
"Hello ECHO DB"

Getting a Non-Existent Key

GET nonexistent

Response:

(nil)

Getting a Key After Deletion

SET mykey "value"
DEL mykey
GET mykey

Response:

OK
(integer) 1
(nil)

Notes

  • GET only works with string values. If the key holds a list, you'll get a WRONGTYPE error
  • Keys are case-sensitive
  • Returns nil if 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
  • SET - Set a key's value
  • EXISTS - Check if a key exists
  • DEL - Delete a key