How cunla/fakeredis-py works
fakeredis is an in-memory, pure-Python Redis-compatible client/server emulator. A caller uses its synchronous or asynchronous client API; commands are handled by the fake server and update shared in-memory database state, with replies returned through the socket/protocol layer. The documented surface also includes server-specific behavior and Redis Stack command families. The tree and excerpts support the main components and data models, but do not show all client-to-server dispatch details, so uncertain wiring is omitted.
Main entry points: commands_mixins Core Commands · _database.py Key Database · _base.py Client Connection · _sync.py Sync Clients
Components 19
Client APIs
- Sync Clients
fakeredis/_clients/_sync.py - Async Clients
fakeredis/_clients/_async.py
Protocol Runtime
- Fake Server
fakeredis/_core/_server.py - Client Connection
fakeredis/_clients/_base.py - Fake Sockets
fakeredis/_socket - RESP Protocol
fakeredis/_socket/_resp.py - TCP Adapter
fakeredis/_clients/_tcp_server.py
Command Emulation
- Command Dispatch
fakeredis/_commands.py - Core Commands
fakeredis/commands_mixins - Transactions
fakeredis/commands_mixins/transactions_mixin.py - Pub/Sub
fakeredis/commands_mixins/pubsub_mixin.py
In-Memory State
- Key Database
fakeredis/_core/_database.py - Value Models
fakeredis/model - Stream Model
fakeredis/model/_stream.py
Server Extensions
- Stack Commands
fakeredis/stack - Dragonfly Commands
fakeredis/server_specific_commands/dragonfly_mixin.py - Geo Utilities
fakeredis/geo - Valkey Support
fakeredis/_clients/_valkey.py
Other components
- Application
Connections 21
- Application → Sync Clients: uses API
- Application → Async Clients: uses API
- Sync Clients → Client Connection: creates connection
- Async Clients → Client Connection: creates connection
- Client Connection → Fake Server: executes commands
- Client Connection → Fake Sockets: uses socket
- Fake Sockets → RESP Protocol: encodes replies
- Fake Server → Command Dispatch: dispatches commands
- Command Dispatch → Core Commands: selects handler
- Core Commands → Key Database: reads and writes
- Core Commands → Value Models: uses values
- Core Commands → Stream Model: uses streams
- Transactions → Key Database: watches keys
- Pub/Sub → Key Database: notifies changes
- Stack Commands → Key Database: stores values
- Stack Commands → Value Models: uses models
- Dragonfly Commands → Key Database: updates state
- Dragonfly Commands → Value Models: uses models
- Geo Utilities → Core Commands: supports geo
- TCP Adapter → Fake Server: hosts server
- Valkey Support → Sync Clients: extends compatibility