Skip to main content
fakeredis

A fast, pure-Python implementation of the Redis protocol — no server required.

PyPI version CI Coverage Downloads Python versions License Open Source Helpers

Documentation · Supported commands · Changelog · Sponsor


fakeredis is a drop-in replacement for redis-py and valkey-py that runs entirely in-memory. Write tests that depend on Redis, Valkey, DragonflyDB, KeyDB, or KiviDB — without spinning up a real server, a container, or a network connection.

import fakeredis

r = fakeredis.FakeStrictRedis()
r.set("foo", "bar")
r.get("foo")  # b'bar'

That's it. No server to install, no port to manage, no teardown.

✨ Why fakeredis?

  • 🚀 Zero setup — no Redis server, Docker, or network required. Pure Python.
  • 🔌 Drop-in compatible — same API as redis.Redis and redis.asyncio.Redis.
  • Fast & isolated — in-memory, so tests run quickly and start from a clean slate.
  • 🧩 Multi-backend — emulate Redis, Valkey, DragonflyDB, KeyDB, or KiviDB, and pin a specific server version.
  • 📦 Redis Stack support — JSON, Bloom/Cuckoo filters, TimeSeries, and Geo commands.
  • 🤝 Share or isolate state — one shared in-memory server across clients, or independent servers per test.

📥 Installation

pip install fakeredis

Optional extras enable additional command families:

pip install "fakeredis[lua]"          # EVAL / EVALSHA scripting
pip install "fakeredis[json]"         # JSON.* commands
pip install "fakeredis[bf]"           # Bloom / Cuckoo / Count-Min / Top-K filters
pip install "fakeredis[probabilistic]"  # alias for the probabilistic filters
pip install "fakeredis[valkey]"       # Valkey client compatibility

🚀 Quickstart

Use it like redis.Redis:

import fakeredis

r = fakeredis.FakeStrictRedis()
r.lpush("queue", "a", "b", "c")
r.lrange("queue", 0, -1)  # [b'c', b'b', b'a']

Share one in-memory server between clients:

server = fakeredis.FakeServer()
r1 = fakeredis.FakeStrictRedis(server=server)
r2 = fakeredis.FakeStrictRedis(server=server)

r1.set("greeting", "hello")
r2.get("greeting")  # b'hello' — same underlying data

Async is supported too:

import fakeredis


async def main():
    r = fakeredis.FakeAsyncRedis()
    await r.set("foo", "bar")
    await r.get("foo")  # b'bar'

Pin a server type and version:

# Behave like Redis 6 — which is what KeyDB is compatible with...
r = fakeredis.FakeStrictRedis(version=6)
# ...or like Valkey, DragonflyDB or KiviDB
r = fakeredis.FakeStrictRedis(server_type="valkey")
r = fakeredis.FakeStrictRedis(server_type="dragonfly")
r = fakeredis.FakeStrictRedis(server_type="kividb")

Using it in tests (pytest)

import pytest
import fakeredis


@pytest.fixture
def redis_client():
    return fakeredis.FakeStrictRedis()


def test_cache_set(redis_client):
    redis_client.set("user:1", "alice")
    assert redis_client.get("user:1") == b"alice"

See the official documentation for the full list of supported commands and configuration options.

❤️ Sponsor

fakeredis-py is developed and maintained for free. If it saves you time, please consider becoming a sponsor — it directly supports continued development.

🤝 Contributing

Contributions are welcome! Check out the contributing guide and the open issues to get started.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fakeredis-2.38.0.tar.gz (271.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fakeredis-2.38.0-py3-none-any.whl (167.4 kB view details)

Uploaded Python 3

File details

Details for the file fakeredis-2.38.0.tar.gz.

File metadata

  • Download URL: fakeredis-2.38.0.tar.gz
  • Upload date:
  • Size: 271.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for fakeredis-2.38.0.tar.gz
Algorithm Hash digest
SHA256 d2abfd24652f86501044499bf08c9d639db050f695eefc06b8b8b6f0bb24dbd6
MD5 34b51eb1aff6de8516f1566be389804e
BLAKE2b-256 bf6bad7db311fea3a62f7e359720cc8c064f06f8f0006e65272f50d3a23d37f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for fakeredis-2.38.0.tar.gz:

Publisher: publish-pypi.yml on cunla/fakeredis-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fakeredis-2.38.0-py3-none-any.whl.

File metadata

  • Download URL: fakeredis-2.38.0-py3-none-any.whl
  • Upload date:
  • Size: 167.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for fakeredis-2.38.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9fb0518c4eaa35f1f2c94df6b4a4c97ff3ca9f43d6cc8112317a9037d244301
MD5 f743c9432fa0e28f9e5d94442367f286
BLAKE2b-256 ec8e9a80a8808e8a723aacb3a5d9df07890b46b363a056b372d3cd2e655259fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for fakeredis-2.38.0-py3-none-any.whl:

Publisher: publish-pypi.yml on cunla/fakeredis-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

2.38.0 This release

2 files

2.37.1

2 files

2.37.0

2 files

2.36.2

2 files

2.36.1

2 files

2.36.0

2 files

2.35.1

2 files

2.35.0

2 files

2.34.1

2 files

2.34.0

2 files

2.33.0

2 files

2.32.1

2 files

2.32.0

2 files

2.31.3

2 files

2.31.1

2 files

2.31.0

2 files

2.30.3

2 files

2.30.2

2 files

2.30.1

2 files

2.30.0

2 files

2.29.0

2 files

2.28.1

2 files

2.28.0

2 files

2.27.0

2 files

2.26.2

2 files

2.26.1

2 files

2.26.0

2 files

2.25.1

2 files

2.25.0

2 files

2.24.1

2 files

2.24.0

2 files

2.23.5

2 files

2.23.4

2 files

2.23.3

2 files

2.23.2

2 files

2.23.1

2 files

2.23.0

2 files

2.22.0

2 files

2.21.3

2 files

2.21.2

2 files

2.21.1

2 files

2.21.0

2 files

2.20.1

2 files

2.20.0

2 files

2.19.0

2 files

2.18.1

2 files

2.18.0

2 files

2.17.0

2 files

2.16.0

2 files

2.15.0

2 files

2.14.1

2 files

2.14.0

2 files

2.13.0

2 files

2.12.1

2 files

2.12.0

2 files

2.11.2

2 files

2.11.1

2 files

2.11.0

2 files

2.10.3

2 files

2.10.2

2 files

2.10.1

2 files

2.10.0

2 files

2.9.2

2 files

2.9.1

2 files

2.9.0

2 files

2.8.0

2 files

2.7.1

2 files

2.7.0

2 files

2.6.0

2 files

2.5.1

2 files

2.5.0

2 files

2.4.0

2 files

2.3.0

2 files

2.2.0

2 files

2.1.0

2 files

2.0.0

2 files

1.10.2

2 files

1.10.1

2 files

1.10.0

2 files

1.9.4

2 files

1.9.3

2 files

1.9.2

2 files

1.9.1

2 files

1.9.0

2 files

1.8.2

2 files

1.8.1

2 files

1.8

2 files

1.7.6

2 files

1.7.5

2 files

1.7.4

2 files

1.7.1

2 files

1.7.0

2 files

1.6.1

2 files

1.6.0

2 files

1.5.2

2 files

1.5.1

2 files

1.5.0

2 files

1.4.5

2 files

1.4.4

2 files

1.4.3

2 files

1.4.2

2 files

1.4.1

2 files

1.4.0

2 files

1.3.1

2 files

1.3.0

2 files

1.2.1

2 files

1.2.0

2 files

1.1.1

2 files

1.1.0

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0

2 files

0.16.0

2 files

0.15.0

2 files

0.14.0

2 files

0.13.1

2 files

0.12.0

2 files

0.11.0

2 files

0.10.3

2 files

0.10.2

2 files

0.10.1

2 files

0.9.0

2 files

0.8.2

2 files

0.8.1

2 files

0.8.0

2 files

0.7.0

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.1

2 files

0.5.0

1 file

0.4.3

2 files

0.4.2

2 files

0.4.1

1 file

0.4.0

1 file

0.3.1

1 file

0.3.0

1 file

0.2.0

1 file

0.1.1

1 file

0.1

1 file

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