Skip to main content

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

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

  1. Use consistent key patterns: type:id:subtype
  2. Tag strategically: Use tags for filtering and categorization
  3. Include metadata: Store searchable metadata for better queries
  4. Set appropriate TTL: Use time-to-live for temporary data

Performance Optimization

  1. Batch operations: Group related operations together
  2. Use pagination: Limit search results and paginate large datasets
  3. Cache frequently accessed data: Store commonly used data in local cache
  4. Monitor storage usage: Track and optimize storage consumption

Security Considerations

  1. Encrypt sensitive data: Use encryption for personal or sensitive information
  2. Validate inputs: Always validate data before storing
  3. Access controls: Implement proper access controls for shared memory spaces
  4. Audit trails: Log access and modifications for security monitoring

Examples

Check out these complete examples: