Command: GET


Overview

The GET command retrieves the value associated with a given key from the in-memory database. If the value is a nested JSON object, an optional path can be provided to extract specific nested fields.

Command Name

GET

Description

Fetches the value associated with a key. If the value is a JSON object or structure, you can extract a specific field using a dot-notated path (e.g., user.name.first ).

Use Cases

  • Retrieve a primitive or complex value stored against a key.

  • Extract a specific field from a nested JSON object.

  • Validate the existence or contents of a key.

Syntax

  GET <key> [<path>]
  
  • <key> : The required key name.

  • <path> (optional): Dot-separated string to retrieve a nested field from a JSON object.

Permissions

  • No authentication is required to use GET .

  • The user must have read access if ACL or user roles are enforced (future extension).


Examples

Example 1: Fetching a Simple Value
  localhost:9219> GET user:1
{"name":"John Doe","age":30}
  
Example 2: Fetching a Nested Value from JSON
  localhost:9219> GET user:1 name
"John Doe"
  
Example 3: Fetching Deeply Nested Value

Stored value:

  {
  "user": {
    "profile": {
      "email": "john@example.com"
    }
  }
}
  
  localhost:9219> GET user:1 user.profile.email
"john@example.com"
  
Example 4: Missing Key
  localhost:9219> GET non_existing_key
(empty response)
  

Behavior on Error

Scenario Error Message
Key not provided ERR invalid key: Key must be provided
Too many arguments ERR invalid args: invalid number of arguments
Invalid key format ERR invalid key: <reason>
Invalid path or non-JSON value ERR invalid character: <JSON error>
Path not found in nested object ERR key not found: <missing key>
Path points to non-object value ERR invalid path: <full path>

Notes

  • Dot notation supports any depth (e.g., a.b.c.d ).