Skip to main content

Storage backends

Where turns live: in the process, a SQLite file, Postgres, MongoDB or your own store.

5 min readUpdated November 2026

Choose a store

Pass a store, a SQLite path or a database URL as the first argument of Memory, or as --db (or LLMSLIM_MEMORY_DB) to llmslim serve and llmslim mcp.

StoreUse
InMemoryStore()Tests and short-lived agents; the default for Memory().
SQLiteStore(path)One file, Python's built-in sqlite3, safe across threads. Memory("memory.db") uses it.
PostgresStore(url)Postgres 12+ (self-hosted, Supabase, Neon, RDS) through psycopg 3, for several processes or machines. Memory("postgresql://...") uses it. pip install "llmslim[postgres]".

SQLite

The default for the command-line tools is ~/.llmslim/memory.db, shared by llmslim mcp and llmslim serve. Back the file up if the memory matters.

sqlite.pypython
from llmslim.memory import Memory

memory = Memory("memory.db")

Postgres

Pass a URL and the store opens a small connection pool; you can pass your own psycopg_pool.ConnectionPool, or an autocommit psycopg.Connection, instead. It creates its table (llmslim_memory, or table=...) and a <table>_meta version table if they don't exist, under an advisory lock, so several processes can start at once. Times are stored as TIMESTAMPTZ and come back in UTC.

postgres.pypython
# pip install "llmslim[postgres]"
from llmslim.memory import Memory

memory = Memory("postgresql://llmslim:<password>@db.example.com:5432/llmslim")
memory.add({"role": "user", "content": "I moved to Pune last month."}, user_id="asha")
print(memory.search("Where did I move to?", user_id="asha").text)
terminalbash
pip install "llmslim[server,postgres]"
LLMSLIM_MEMORY_DB="postgresql://llmslim:<password>@db.example.com:5432/llmslim" llmslim serve --host 0.0.0.0

Pass the URL in the environment rather than as --db, so the password stays out of the process list.

Your own store

A store only persists and lists turns. Any object with the MemoryStore methods works, so another database can plug in without changing selection:

  • add(items), list(scope, since=None, until=None) (oldest first), get(item_id);
  • update(item_id, content=None, metadata=None), delete(item_id), delete_scope(scope).

The signatures are in the API reference.

Questions

Does the store change what search returns?

No. A store only persists and lists turns; selection is the same on every store.

Can several processes share one memory?

A few processes on one host can share a SQLite file. For more, or for servers on several hosts, use Postgres.