Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Tests & Lint PyPI Downloads Monthly Downloads License Documentation

🗄️ synced-memory

A production-ready Python class for seamless, multiprocessing-safe, persistent key-value storage using Redis or DragonflyDB as a backend. If the backend is unavailable, values are cached locally and queued for syncing when it comes back online. All values are serialized as JSON, and you interact with it using natural Python attribute access.

Purpose

The intention is to use this with agentic workflows deployed as microservices, allowing for multiple instances of the same pod to share their state.

✨ Features

  • 🔄 Multiprocessing-safe: All processes share the same state via Redis or DragonflyDB.
  • 🧠 Pythonic API: Set and get attributes as if they were regular object properties.
  • 🕰️ Persistence: Values survive process restarts and context blocks.
  • 🚦 Resilient: If the backend is down, changes are queued and flushed when it returns.
  • 🧩 Customizable: Prefixes and conversation IDs for namespacing.
  • 🧵 Background sync: Queued changes are flushed automatically in the background.

🚀 Quickstart

pip install synced-memory
from synced_memory.redis import Memory

mem = Memory()
mem.answer = 42
print(mem.answer)  # 42

# Across processes or instances:
mem2 = Memory()
print(mem2.answer)  # 42

mem.settings = {"theme": "dark", "volume": 0.75}
print(mem.settings)  # {'theme': 'dark', 'volume': 0.75}

To use DragonflyDB instead:

from synced_memory.dragonflydb import Memory

mem = Memory()
mem.answer = 42

🧑‍💻 Context Management

You can use Memory as a context manager for automatic resource handling:

with Memory() as memory:
    memory.session = "active"
    print(memory.session)  # "active"

# Later, in a new context:
with Memory() as memory:
    print(memory.session)  # "active"

🔄 Auto-Synced Collections

Lists and dictionaries are automatically wrapped as SyncedList and SyncedDict, which sync changes to the backend immediately:

mem = Memory()
mem.items = [1, 2, 3]
mem.items.append(4)  # Automatically syncs

mem2 = Memory()
print(mem2.items)  # [1, 2, 3, 4]

mem.config = {"theme": "dark"}
mem.config["lang"] = "en"  # Automatically syncs
print(mem2.config)  # {'theme': 'dark', 'lang': 'en'}

Nested structures work too:

mem.data = {"user": {"preferences": {"color": "blue"}}}
mem.data["user"]["preferences"]["color"] = "red"  # Syncs!

Converting to Plain Python Types

For libraries that need plain Python objects (serialization, pickling, etc.):

mem.items = [1, 2, 3]
plain_list = mem.items.aslist()  # Returns regular list

mem.config = {"key": "value"}
plain_dict = mem.config.asdict()  # Returns regular dict

import pickle
pickle.dump(plain_list, file)  # Works!

🗂️ Namespacing

By default, synced-memory uses memory: as its key prefix. Override with REDIS_PREFIX:

mem = Memory()
mem.state = {"step": 1}
print(mem.state)  # {'step': 1}

Scoping

Use PrefixedMemory to isolate memory by a custom scope prefix:

from synced_memory.redis import PrefixedMemory

mem = PrefixedMemory(prefix="session_abc123")
mem.state = {"step": 1}
print(mem.state)  # {'step': 1}

⚙️ Environment Variables

  • REDIS_HOST: Backend hostname (default: redis)
  • REDIS_PORT: Backend port (default: 6379)
  • REDIS_PREFIX: Key prefix (default: memory:)

--- WHEN UPDATING README.md: YOU CAN KEEP EVERYTHING BELOW THIS LINE ---

🛠️ Development

The only requirement is 🐳 Docker. (The .devcontainer and tasks.json are prepared assuming a *nix system, but if you know the commands, this will work on Windows, too.)

  1. Clone the repo.
  2. Branch out.
  3. Open in "devcontainer" on VS Code and start developing. Run pytest under tests to test.
  4. Alternatively, if you are a fan of Test-Driven Development like me, you can run the tests without getting on a container. .vscode/tasks.json has the command to do so, but it's also listed here:
docker compose -f tests/docker-compose.yaml up --build --abort-on-container-exit --exit-code-from test

Metadata

Release files for synced-memory 0.1.2.dev202605010255

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for synced-memory 0.1.2.dev202605010255
File Size Uploaded
synced_memory-0.1.2.dev202605010255.tar.gz 15.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for synced-memory 0.1.2.dev202605010255
File Interpreter ABI Platform
synced_memory-0.1.2.dev202605010255-py3-none-any.whl Python 3 none any Details

Total release size: 25.9 kB

Release files / synced_memory-0.1.2.dev202605010255.tar.gz

Download URL synced_memory-0.1.2.dev202605010255.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e5dd5f4f41465cd1b2ea8d4c8727e70dd95566b27017a90b984183a58023a19c
BLAKE2b-256 checksum
How to use checksums
e2e959bd7e31a081d399b25e1c76874a948d25a73d479f2b55c098f19149da98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 1, 2026.

Transparency log

Release files / synced_memory-0.1.2.dev202605010255-py3-none-any.whl

Download URL synced_memory-0.1.2.dev202605010255-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9fd4d134f65534e945676359f0d3cb707723d498e6ad0e61fc505a152207b679
BLAKE2b-256 checksum
How to use checksums
221cedeb0e88ce36f9f07ae8d76a63734a3877e6f64f31d578ab0a22158730e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 1, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.3

2 release files

0.1.2

2 release files

This release

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page