Memory
The Memory module provides persistent storage capabilities for AI applications, enabling agents and chat systems to remember context, user preferences, and important information across sessions.Overview
The Memory system is built on the 0G decentralized storage network, providing:- Persistent Storage: Data survives application restarts and deployments
- Decentralized: No single point of failure
- Searchable: Full-text search and tag-based filtering
- Scalable: Handles large amounts of data efficiently
- Secure: Encrypted storage with access controls
Basic Usage
Configuration Options
Option | Type | Default | Description |
---|---|---|---|
storageKey | string | required | Unique identifier for your memory space |
apiKey | string | required | Your API key for authentication |
encryption | boolean | true | Whether to encrypt stored data |
compression | boolean | true | Whether to compress data before storage |
ttl | number | null | Default time-to-live for entries (seconds) |
Memory Patterns
User Context Storage
Conversation Memory
Knowledge Base
Integration with Chat
Context-Aware Conversations
Advanced Features
Memory Hierarchies
Memory Analytics
Best Practices
Data Organization
- Use consistent key patterns:
type:id:subtype
- Tag strategically: Use tags for filtering and categorization
- Include metadata: Store searchable metadata for better queries
- Set appropriate TTL: Use time-to-live for temporary data
Performance Optimization
- Batch operations: Group related operations together
- Use pagination: Limit search results and paginate large datasets
- Cache frequently accessed data: Store commonly used data in local cache
- Monitor storage usage: Track and optimize storage consumption
Security Considerations
- Encrypt sensitive data: Use encryption for personal or sensitive information
- Validate inputs: Always validate data before storing
- Access controls: Implement proper access controls for shared memory spaces
- Audit trails: Log access and modifications for security monitoring