Best Practices

Guidelines for getting the most out of Memori in development and production.

Top 5 Rules

  1. Use PostgreSQL in production — handles concurrent writes, connection pooling, and multi-server scaling. SQLite is for development only.
  2. Always set attribution — call mem.attribution(entity_id=..., process_id=...) before every interaction for proper memory isolation.
  3. Store API keys in environment variables — never hardcode. Use .env locally, secrets managers in production.
  4. Run config.storage.build() once — at startup or in your deploy pipeline, not on every request.
  5. Tune recall limitsrecall(query, limit=N) with appropriate limits. Fewer results = faster; more = richer context.

Guides

Database Selection

Choosing the right database for your use case.

Learn more →

Async Patterns

Using Memori with async/await and web servers.

Learn more →

Security

API keys, credentials, entity isolation, and encryption.

Learn more →

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.