Skip to main content
AI agents need a place to store what they’ve learned during a conversation — the user’s name, their preferences, the last topic discussed — and retrieve it on the next turn without passing the entire history through the context window. Cache-Pot’s REMEMBER and RECALL commands provide session-scoped key-value memory built directly into the store. Because it’s backed by Cache-Pot’s native hash type, you get persistence across restarts, optional TTL-based expiry, and direct hash access — all without any extra infrastructure.

How agent memory works

1

Store a fact

Call REMEMBER with a session identifier, a field name, and the value. Cache-Pot writes the field into a hash at the key mem:<session>.
2

Retrieve a specific field

Call RECALL with the session and field name to get a single value.
3

Retrieve the whole session

Omit the field argument to get all stored fields and values for the session.
REMEMBER session field value is equivalent to HSET mem:session field value, and RECALL session is equivalent to HGETALL mem:session. You can use hash commands directly on mem:<session> if you need finer control.

Basic example


Setting TTL on agent memory

Sessions are persistent by default. Use EXPIRE on the underlying mem:<session> key to make a session expire automatically:
Use EXPIRE on a session after every interaction to implement a sliding inactivity timeout — each new REMEMBER call refreshes the window.

Multi-agent example

The snippet below shows an agent storing context during one turn and reading it back on a subsequent turn, using the standard redis-py client.

Using via MCP

Agent memory is also accessible from Cache-Pot’s built-in MCP server. AI frameworks that support the Model Context Protocol can call the remember and recall tools directly — no Redis client required. See the MCP integration guide for setup instructions and a full list of available tools.
Use descriptive, collision-resistant session names such as user-<uuid> or conversation-<uuid>. Because all session hashes share the same keyspace under the mem: prefix, a predictable naming scheme prevents one session from accidentally overwriting another.