valkey-embedded
Embedded, auto-managed Valkey server for Python. Construct a
client and a private valkey-server starts; it shuts down and cleans up when the
last client closes. No separate server install or running daemon required.
from valkey_embedded import Valkey
conn = Valkey()
conn.set("key", "value")
conn.get("key") # b'value'
# server is stopped and cleaned up when the process exits
This project is motivated by redislite — the same embed-the-real-engine idea, reimplemented from scratch under BSD-3-Clause and targeting Valkey so the embedded binary can be freely redistributed on PyPI.
When to use valkey-embedded
valkey-embedded runs the real Valkey engine as an embedded, auto-managed server on a single machine, persisting via RDB snapshots (a cache/buffer, not a durable system-of-record). Those four properties decide where it fits.
Strong fit — this is what it's for:
- Testing Redis/Valkey code. Every
Valkey()is a private, clean server, so tests isolate cleanly and run in parallel. Because it's the real engine, expiry, eviction, blocking ops,MULTI/EXEC, and your Lua scripts behave exactly as in production — unlike reimplementations that drift. - CI without service containers. No
services: redis, no docker-compose, no testcontainers, no "wait for healthy" — justpip installand run. - Local development & onboarding. Clone, run, works. No daemon to install or keep alive; the binary is bundled, so it works offline.
- Demos, tutorials, notebooks. Ship something that just runs, with zero prerequisites.
Works, with caveats:
- Single-box inter-process coordination / queues (shared mode). Treat it as an
ephemeral buffer unless you open it with
connect(path, durable=True); don't call.shutdown()from one process while others share the server; setmaxmemoryand TTLs to bound memory growth. - Local cache for a single-node app or CLI. Reach for it when you specifically want Redis data structures, pub/sub, or TTL semantics — otherwise SQLite is simpler.
Wrong tool — use something else:
| You want… | Use instead |
|---|---|
| Production serving, HA, or multi-host | a real Valkey/Redis deployment |
| A durable system-of-record | PostgreSQL |
| A durable single-file in-process database | SQLite |
| Cross-machine shared state | a real Valkey/Redis deployment |
| Windows-native (without WSL) | a real Valkey/Redis deployment |
In short: valkey-embedded owns the "I need the real Valkey engine, on one box, with zero infra — mostly for testing and local dev" niche. It is an embedded server, not an in-process database.
Install
pip install valkey-embedded # prebuilt wheels: Linux x86_64, macOS 14+ arm64
Other POSIX platforms build Valkey from source at install time (needs gcc/clang
and make). Windows is unsupported (WSL works).
Usage
-
Isolated server:
Valkey()— a private server per instance. -
Persistent / shared:
Valkey("/path/to/db.rdb")— persists across runs; instances sharing the path attach to one server (last to close shuts it down).Note: the first positional argument is the RDB file path, not
host— the embedded server has no host. Pass server overrides viaserverconfig={"maxmemory": "64mb"}. -
SQLite-style open with durability:
connect()is sugar overValkey()that reads likesqlite3.connect— open a file-backed store, opt into crash-safety, and release it by leaving awithblock:import valkey_embedded with valkey_embedded.connect("data.db", durable=True) as db: db.set("user:1", "ada") # AOF-backed: survives a crash, not just a clean exit # leaving the block persists and stops the embedded server
durable=Trueenables the append-only file withappendfsync everysec(≤1s of writes lost on a crash);durable="always"fsyncs every write. Default (durable=False) is RDB snapshots only, which can lose writes since the last snapshot.durable=requires a path — an isolated server's data is discarded on exit. Force a snapshot anytime withdb.bgsave(). -
Explicit server with a TCP endpoint:
ValkeyServeris the other half of the API — you control start/stop, and the server listens on host/port so any Redis-compatible client (or another process) can connect:from valkey_embedded import ValkeyServer with ValkeyServer() as server: # port auto-assigned; or ValkeyServer(port=6380) print(server.connection_url) # valkey://127.0.0.1:<port> client = server.client() # built-in valkey-py client client.set("k", "v") # bring your own: valkey.Valkey(**server.connection_kwargs)
Explicit form:
server = ValkeyServer(); server.start(); ...; server.stop()(is_running(),terminate(),persist=True,data_dir=…,config={…}too).Valkey()stays unix-socket-only with no TCP listener (private by default); reach forValkeyServerwhen you need a port. -
Pytest fixtures: installing the package registers fixtures automatically — no conftest wiring. One server runs per test session; each test gets a client with a clean keyspace (
FLUSHALLon setup):def test_thing(valkey_client): # client to the session server, keys wiped per test valkey_client.set("k", "v") assert valkey_client.get("k") == b"v" def test_other(valkey_server, valkey_url): assert valkey_server.is_running() # the session ValkeyServer; valkey_url is its URL def test_pristine(valkey_server_factory): private = valkey_server_factory(persist=False) # fresh server just for this test assert private.client().ping()
Only keys are reset between tests; server-level state (
CONFIG SET, loaded Lua scripts) persists for the session — usevalkey_server_factorywhen a test needs a pristine process. Under pytest-xdist each worker gets its own server. -
Command line: run a server in the foreground:
valkey-embedded --port 6380 # or: python -m valkey_embedded
-
Diagnostics:
python -m valkey_embedded.debug -
Errors: failures to start the embedded server raise
valkey_embedded.ServerStartError; its base classValkeyEmbeddedErrorcatches every error this library raises. (Command errors from the server itself are raised byvalkey-pyas usual.) -
Also exported:
StrictValkey(alias ofValkey, mirroring valkey-py);durable="everysec"as the explicit spelling ofdurable=True;__valkey_executable__(path to the bundledvalkey-server) and__valkey_server_version__(its version, e.g.8.1.8). A bundledvalkey-cliships next to the server binary for manual inspection:import os, valkey_embedded cli = os.path.join(os.path.dirname(valkey_embedded.__valkey_executable__), "valkey-cli")
Examples
Runnable scripts for each feature live in examples/ (basic usage,
persistence, shared vs. isolated servers, patching, serverconfig, replication,
and diagnostics):
python examples/01_basic.py
Migration from redislite
| redislite | valkey-embedded |
|---|---|
redislite.Redis |
valkey_embedded.Valkey |
redislite.patch.patch_redis |
valkey_embedded.patch.patch_valkey |
Valkey is wire-compatible with Redis and valkey-py is forked from redis-py, so
application logic is unchanged — only imports and class names differ.
Versioning & support
valkey-embedded follows Semantic Versioning. While on
0.x the API may still change between minor versions; any change is recorded in
CHANGELOG.md. Supported Python versions are 3.9–3.13 on Linux and
macOS (14+ arm64); Windows is supported only under WSL.
Contributing
See CONTRIBUTING.md for dev setup, the test tiers, and the procedure for pinning a new Valkey release. Participation is governed by our Code of Conduct; security issues go through SECURITY.md.
License
valkey-embedded is licensed under BSD-3-Clause. Built wheels
bundle a compiled valkey-server binary, also BSD-3-Clause; its license — and
the notices of the third-party code statically linked into it (Lua,
hdr_histogram, fpconv, linenoise) — ship as valkey_embedded/bin/VALKEY_COPYING.txt
alongside the binary. The valkey Python client is a runtime dependency, not
redistributed here.
Trademark
valkey-embedded is an independent project and is not affiliated with, sponsored, or endorsed by the Valkey project or the Linux Foundation. Valkey is a trademark of LF Projects, LLC.
Metadata
Release files for valkey-embedded 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| valkey_embedded-0.1.0.tar.gz | 35.1 kB | Details |
Built distributions (wheels)
Total release size: 36.1 MB
Release files / valkey_embedded-0.1.0.tar.gz
| Download URL | valkey_embedded-0.1.0.tar.gz |
|---|---|
| Size | 35.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
817e0d37588a4641da3326a84327cf124bae4eb4b2012a3186950d195080ebb5
|
|
BLAKE2b-256 checksum How to use checksums |
56b8ee35a2fd4b6d2a9a470efb7948bb094b514cebf686d14f0c31ebb40da101
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jun 18, 2026.
Transparency logRelease files / valkey_embedded-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | valkey_embedded-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 6.0 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
4c0e821d34eef2bcee445f4f14a78093b47670c3250247adab7a209e55c9922f
|
|
BLAKE2b-256 checksum How to use checksums |
50510d7f27080c5119c1fe3bb393497af58934816963d944851f6931970f6ae9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jun 18, 2026.
Transparency logRelease files / valkey_embedded-0.1.0-cp313-cp313-macosx_14_0_arm64.whl
| Download URL | valkey_embedded-0.1.0-cp313-cp313-macosx_14_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.13 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
9e94df3e5258a49bc5671393c33b5df027eeea4bf6567883a16738aeb49a62a2
|
|
BLAKE2b-256 checksum How to use checksums |
33c02cfd1df715556bfca99eb686c2e96eac70ff6540bef082e79b2824bd659a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jun 18, 2026.
Transparency logRelease files / valkey_embedded-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | valkey_embedded-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 6.0 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
6dff5707af3c81c4c2edd408f9eddae4fe66fcee60678769f39e817800463d82
|
|
BLAKE2b-256 checksum How to use checksums |
0895f9b5c823c173b92369bd4534fcb300afa576cb5a837c26ab31f7ca745ad7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jun 18, 2026.
Transparency logRelease files / valkey_embedded-0.1.0-cp312-cp312-macosx_14_0_arm64.whl
| Download URL | valkey_embedded-0.1.0-cp312-cp312-macosx_14_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.12 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
bc0341b6f11c782984851c3ac68e7620afbb7d57fdc4735cae7195bc446e6f89
|
|
BLAKE2b-256 checksum How to use checksums |
28a7147656c025fcf2669aad5e20ed694a6651526f434ea5b5ca6f90c88b23ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jun 18, 2026.
Transparency logRelease files / valkey_embedded-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | valkey_embedded-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 6.0 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
5bae222b82e6390f55a0b4fa3a6a24e9189af16901482e99b6c344f2ad425b8d
|
|
BLAKE2b-256 checksum How to use checksums |
289abcfa90bf4818633dd476bbe4d5b3e144ec4179a3f9fda026a831fcc808ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jun 18, 2026.
Transparency logRelease files / valkey_embedded-0.1.0-cp311-cp311-macosx_14_0_arm64.whl
| Download URL | valkey_embedded-0.1.0-cp311-cp311-macosx_14_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.11 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
9a4bc4ecf80953dc59b9c480797aeee4c597de2910d07bf638d798c804365322
|
|
BLAKE2b-256 checksum How to use checksums |
46505ce820bd83e61e0b9865d08cecf7684d2f2fa25d15dd61d9fb102cadb72c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jun 18, 2026.
Transparency logRelease files / valkey_embedded-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | valkey_embedded-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 6.0 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
b7f1144ef6ee49b515950620f6a1b4eebd396daa1e85355cd3a0a3144407ddca
|
|
BLAKE2b-256 checksum How to use checksums |
04c9b88f7335ca1a156d7c76a56505bc11c100c4392a28b56050d7e5bd4c411a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jun 18, 2026.
Transparency logRelease files / valkey_embedded-0.1.0-cp310-cp310-macosx_14_0_arm64.whl
| Download URL | valkey_embedded-0.1.0-cp310-cp310-macosx_14_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.10 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d960b5fc53b5187793da20b19bef9f36ddc113eb7b4dffdf9f7f105ff03f34ac
|
|
BLAKE2b-256 checksum How to use checksums |
bc0c03143744e958b920671a6237ddac87bb6655294a8d53b7da9b79a98619bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jun 18, 2026.
Transparency logRelease files / valkey_embedded-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | valkey_embedded-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 6.0 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
1ee5f3a2b7210024743e789ef9ae1a720c82d4e45f68904b393fb446a7541dd8
|
|
BLAKE2b-256 checksum How to use checksums |
8845b2a1b641f3e31e763b6c98f7caf1668d17ee7a439d6945c2bd0862cb4172
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jun 18, 2026.
Transparency logRelease files / valkey_embedded-0.1.0-cp39-cp39-macosx_14_0_arm64.whl
| Download URL | valkey_embedded-0.1.0-cp39-cp39-macosx_14_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.9 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b9e654ed23aa85aea6cb1057ebd513899bc2a646c7cc5416feec8eaadfe2b381
|
|
BLAKE2b-256 checksum How to use checksums |
01988bd47bcaabebd67a937fb1fdcff0e50018eae693973913d42f1055032e5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jun 18, 2026.
Transparency log