Providers
Storage Providers

Storage Providers

L2 storage providers handle persistent memory storage.

SQLite

Local development and single-user applications.

Installation

pip install remina-memory[sqlite]

Configuration

"storage": {
    "provider": "sqlite",
    "config": {
        "path": "~/.remina/memories.db",
        "collection_name": "memories",
    }
}
OptionTypeDefaultDescription
pathstr~/.remina/memories.dbDatabase file path
collection_namestrmemoriesTable name

Characteristics:

  • Zero configuration
  • No external dependencies
  • File-based persistence
  • Not suitable for concurrent access
  • Single-node only

PostgreSQL

Production multi-user applications.

Installation

pip install remina-memory[postgres]

Configuration

"storage": {
    "provider": "postgres",
    "config": {
        "host": "localhost",
        "port": 5432,
        "database": "remina",
        "user": "postgres",
        "password": "password",
        "collection_name": "memories",
        "min_connections": 1,
        "max_connections": 10,
    }
}
OptionTypeDefaultDescription
hoststrlocalhostDatabase host
portint5432Database port
databasestrreminaDatabase name
userstrrequiredDatabase user
passwordstrrequiredDatabase password
collection_namestrmemoriesTable name
min_connectionsint1Min pool connections
max_connectionsint10Max pool connections

Setup

docker run -d \
  --name remina-postgres \
  -e POSTGRES_USER=remina \
  -e POSTGRES_PASSWORD=remina \
  -e POSTGRES_DB=remina \
  -p 5432:5432 \
  postgres:15

Characteristics:

  • Production-ready
  • ACID compliance
  • Connection pooling
  • Horizontal scaling (read replicas)

MongoDB

Document-heavy workloads and flexible schemas.

Installation

pip install remina-memory[mongodb]

Configuration

"storage": {
    "provider": "mongodb",
    "config": {
        "uri": "mongodb://localhost:27017",
        "database": "remina",
        "collection_name": "memories",
    }
}
OptionTypeDefaultDescription
uristrmongodb://localhost:27017Connection URI
databasestrreminaDatabase name
collection_namestrmemoriesCollection name

Setup

docker run -d \
  --name remina-mongo \
  -p 27017:27017 \
  mongo:7

Characteristics:

  • Flexible schema
  • Horizontal scaling (sharding)
  • Rich document queries
  • Built-in replication

Storage Interface

All storage providers implement:

class StorageBase(ABC):
    async def save(self, memories: List[Memory]) -> None
    async def get(self, ids: List[str]) -> List[Memory]
    async def delete(self, ids: List[str]) -> None
    async def query(self, user_id: str, filters: Dict = None, limit: int = 100) -> List[Memory]
    async def update(self, memory: Memory) -> None
    async def count(self, user_id: str) -> int
    async def close(self) -> None

Custom Implementation

from remina.storage.base import StorageBase
from remina.models import Memory
from typing import List, Dict, Any, Optional
 
class MyCustomStorage(StorageBase):
    def __init__(self, config: Optional[Dict[str, Any]] = None):
        super().__init__(config)
        
    async def save(self, memories: List[Memory]) -> None:
        pass
    
    async def get(self, ids: List[str]) -> List[Memory]:
        return []
    
    async def delete(self, ids: List[str]) -> None:
        pass
    
    async def query(self, user_id: str, filters: Dict = None, limit: int = 100) -> List[Memory]:
        return []
    
    async def update(self, memory: Memory) -> None:
        await self.save([memory])
    
    async def count(self, user_id: str) -> int:
        return 0
    
    async def close(self) -> None:
        pass