Skip to main content

vkmem for Python

vkmem starts the Go vkmem-server binary as a child process and returns a normal Redis/Valkey DSN. Existing clients such as redis-py, valkey-py, redis-om, and SQL-free test helpers can use it without an adapter.

pip install vkmem redis
import redis
import vkmem

with vkmem.start() as server:
    client = redis.Redis.from_url(server.dsn)
    client.set("answer", 42)
    assert client.get("answer") == b"42"
    client.close()

Prepared snapshots

Prepare a template once, then fork an independent Valkey server for each test. snapshot() writes a synchronous RDB into vkmem's in-memory filesystem; fork() starts a new guest over a private copy of that filesystem. Connections and server runtime state are not copied.

import redis
import vkmem

with vkmem.start() as process:
    prepare(redis.Redis.from_url(process.template.dsn))
    snapshot = process.template.snapshot(max_forks=4)
    try:
        with snapshot.fork() as fork:
            client = redis.Redis.from_url(fork.dsn)
            # Starts with the prepared keyspace; writes stay in this fork.
            client.set("test-only", "value")
            client.close()
    finally:
        snapshot.close()

The package also registers pgmem-style pytest fixtures when pytest is installed. Override vkmem_snapshot to prepare data, then use vkmem_fork or vkmem_dsn in each test. vkmem_class_fork and vkmem_class_dsn share one fork for a test class.

# conftest.py
import pytest
import redis

@pytest.fixture(scope="session")
def vkmem_snapshot(vkmem_server):
    client = redis.Redis.from_url(vkmem_server.dsn)
    prepare(client)
    client.close()
    return vkmem_server.snapshot(max_forks=4)

# test_orders.py
def test_write_isolated(vkmem_dsn):
    client = redis.Redis.from_url(vkmem_dsn)
    client.set("order:1", "ready")
    client.close()

The server exposes these useful attributes:

  • server.dsn / server.url: redis://127.0.0.1:<port>
  • server.host, server.port, and server.addr
  • server.unix_socket: the Unix socket path, when enabled
  • server.pid, server.version, and server.valkey_version

Pass Valkey server arguments after args, choose a port, or disable the Unix socket when a test only needs TCP:

with vkmem.start(
    args=["--maxmemory", "32mb"],
    unix_socket=False,
    timeout=30,
) as server:
    client = redis.Redis.from_url(server.dsn)

Binary lookup uses VKMEM_SERVER_BIN, then the binary bundled in the platform wheel, then vkmem-server on PATH. vkmem.find_binary() exposes that lookup directly. A local checkout can use binary="/path/to/vkmem-server".

The wheel has no runtime Python dependencies. It bundles a static binary for Linux x86_64/aarch64, macOS arm64, and Windows x86_64/arm64. The Go binary also exits when the Python process closes its stdin pipe or disappears, so a test failure does not leave a server running.

Metadata

Release files for vkmem 0.1.2

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

Built distributions (wheels)

Table of built distributions (wheels) for vkmem 0.1.2
File
vkmem-0.1.2-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details
vkmem-0.1.2-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
vkmem-0.1.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64, Linux musl 1.1+ x86-64 Details
vkmem-0.1.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64, Linux musl 1.1+ ARM64 Details
vkmem-0.1.2-py3-none-macosx_12_0_arm64.whl Python 3 none macOS 12.0+ ARM64 Details

Total release size: 22.9 MB

Release files / vkmem-0.1.2-py3-none-win_arm64.whl

Download URL vkmem-0.1.2-py3-none-win_arm64.whl
Size 4.4 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
9058c5e5a126d1efa1f23bc3a9342b6b735469cd0b974a99a118fc99f5b73f61
BLAKE2b-256 checksum
How to use checksums
aa65381b4fe252c7156bfa6fc3124d99784f66602fa26bf992f3e9b3a4122482
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 16, 2026.

Transparency log

Release files / vkmem-0.1.2-py3-none-win_amd64.whl

Download URL vkmem-0.1.2-py3-none-win_amd64.whl
Size 4.9 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
413b88d0ff7a694017d41b2311822e4fad12d88f3d2b9c87bb8db669ed9e2e5e
BLAKE2b-256 checksum
How to use checksums
4c96ec67f486986e18d70c4b0eee411f7dc2e80b0f3987087fc854219080c02f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 16, 2026.

Transparency log

Release files / vkmem-0.1.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl

Download URL vkmem-0.1.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl
Size 4.8 MB
Tags Linux glibc 2.17+ x86-64 Linux musl 1.1+ x86-64 Python 3
SHA-256 checksum
How to use checksums
6768ac9a464af6cae5c22e1acacd41362d90a691b8c113590b0d1bf2abf262ae
BLAKE2b-256 checksum
How to use checksums
1d290ef60ee0ff1c8de66f44b80dd4dc845c9642f8aec4a813aca8358bd39eff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 16, 2026.

Transparency log

Release files / vkmem-0.1.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl

Download URL vkmem-0.1.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl
Size 4.4 MB
Tags Linux glibc 2.17+ ARM64 Linux musl 1.1+ ARM64 Python 3
SHA-256 checksum
How to use checksums
4bbdfcaebeaada90f271a5b28eea11d34d4f5755661960d44c2878cca66ab28a
BLAKE2b-256 checksum
How to use checksums
84d21a65e7c23cbb3fcc4cb39e8769be3deb32954621831090b82f40b99bba80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 16, 2026.

Transparency log

Release files / vkmem-0.1.2-py3-none-macosx_12_0_arm64.whl

Download URL vkmem-0.1.2-py3-none-macosx_12_0_arm64.whl
Size 4.5 MB
Tags Python 3 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
a4fe311ba8391e2106b3860f96190581f2ddb14c456bedff86a58185c4e98ba9
BLAKE2b-256 checksum
How to use checksums
55064a484cefea06651bc6f8907aa75dee2c95325623f0edb8c0f8413a4b68e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

5 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