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",
}
}| Option | Type | Default | Description |
|---|---|---|---|
path | str | ~/.remina/memories.db | Database file path |
collection_name | str | memories | Table 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,
}
}| Option | Type | Default | Description |
|---|---|---|---|
host | str | localhost | Database host |
port | int | 5432 | Database port |
database | str | remina | Database name |
user | str | required | Database user |
password | str | required | Database password |
collection_name | str | memories | Table name |
min_connections | int | 1 | Min pool connections |
max_connections | int | 10 | Max 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:15Characteristics:
- 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",
}
}| Option | Type | Default | Description |
|---|---|---|---|
uri | str | mongodb://localhost:27017 | Connection URI |
database | str | remina | Database name |
collection_name | str | memories | Collection name |
Setup
docker run -d \
--name remina-mongo \
-p 27017:27017 \
mongo:7Characteristics:
- 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) -> NoneCustom 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