Skip to main content

Retrieve Memory

Retrieve stored data from the 0G decentralized storage network.

Method

Parameters

string
required
The unique identifier of the memory entry to retrieve

Response

Returns a MemoryEntry object if found, or null if the key doesn’t exist.

MemoryEntry Properties

string
The unique identifier of the entry
any
The stored data (automatically deserialized)
Record<string, any>
Additional metadata associated with the entry
string[]
Tags associated with the entry
Date
When the entry was stored
number
Time-to-live in seconds (if set)
Date
When the entry expires (if TTL is set)

Examples

Advanced Usage

Conditional Retrieval

Version Management

Cache Pattern

Integration Patterns

Chat Context Retrieval

User Profile Management

Configuration Management

Error Handling

Performance Optimization

Parallel Retrieval

Selective Loading

Best Practices

  1. Handle null returns gracefully with default values
  2. Check expiration before using retrieved data
  3. Use parallel retrieval for related data
  4. Implement caching for frequently accessed data
  5. Validate data integrity after retrieval