Best Practices
Guidelines for getting the most out of Memori in development and production.
Top 5 Rules
- Use PostgreSQL in production — handles concurrent writes, connection pooling, and multi-server scaling. SQLite is for development only.
- Always set attribution — call
mem.attribution(entity_id=..., process_id=...)before every interaction for proper memory isolation. - Store API keys in environment variables — never hardcode. Use
.envlocally, secrets managers in production. - Run
config.storage.build()once — at startup or in your deploy pipeline, not on every request. - Tune recall limits —
recall(query, limit=N)with appropriate limits. Fewer results = faster; more = richer context.
Guides
Quick Tips
Development — Use SQLite, set echo=True to see SQL, call augmentation.wait() in scripts.
Production — Use PostgreSQL with pool_pre_ping=True and pool_recycle=300. Store credentials in a secrets manager. Pre-download embeddings with python -m memori setup.