# Memorylake

### Introduction <a href="#introduction" id="introduction"></a>

Memorylake is a tool that allows users to efficiently store, retrieve, and manage key-value pairs in Redis using a structured format. This guide will explain how to use Memorylake with practical examples and small code snippets to help you get started.

### How Memorylake Works <a href="#how-memorylake-works" id="how-memorylake-works"></a>

Memorylake uses Redis as a key-value store. Each piece of stored information consists of:

* **Key**: A unique identifier generated using `memory_context` values.
* **Value**: A structured JSON-like object that stores query-response data along with metadata.

As we are using Redis pipelines, the concept remains the same—we store keys with values.

### Key Structure <a href="#key-structure" id="key-structure"></a>

The key is generated using the following structure:

```
user_uuid:context_entity_id:context_id:memory_id
```

**Breakdown of Key Components**

* `user_uuid`: The unique identifier of the user.
* `context_entity_id`: Represents the broader category or application where the memory is being stored. This could be a chatbot, a recommendation system, or an AI assistant. It helps in categorizing and differentiating different applications of stored memory.
* `context_id`: Represents a specific session, instance, or interaction within the `context_entity_id`. For example, in a chatbot, this could be a conversation session, while in a support ticketing system, it could be a ticket ID.
* `memory_id`: A unique identifier for the specific memory entry within a session or interaction. This allows multiple memory records to be stored under the same `context_id`, tracking multiple interactions within the same session.

```
├── user_uuid
│   └── context_entity_id
│       └── context_id
│           └── memory_id
```

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.groclake.ai/lakes/agent-management-and-deployment/memorylake.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
