Store Memory
Store data persistently in the 0G decentralized storage network for AI agents and applications.Method
Parameters
MemoryEntry
required
The memory entry to store
string
required
Unique identifier for the memory entry
any
required
The data to store (will be JSON serialized)
Record<string, any>
Additional metadata for the entry
string[]
Tags for categorizing and searching the entry
number
Time-to-live in seconds (optional expiration)
Response
boolean
Whether the storage operation succeeded
string
The key of the stored entry
string
The content hash on the 0G network
Date
When the entry was stored
number
Size of the stored data in bytes
Examples
Advanced Usage
Conditional Storage
Versioned Storage
Large Data Storage
Error Handling
Storage Patterns
Cache Pattern
Event Sourcing
Best Practices
Key Naming
Data Validation
Performance Tips
- Batch operations when storing multiple entries
- Use appropriate TTL to prevent storage bloat
- Compress large data before storing
- Use tags efficiently for better search performance
- Monitor storage usage to avoid quota issues