How emmmik/klyn works
klyn is a Redis-compatible in-memory key-value server. A client sends RESP over TCP; the server parses a frame, dispatches its command to the database, encodes the response, and writes it back. The database provides key operations, counters, and lazy TTL handling, while AOF logging and startup replay provide persistence. The README documents concurrency and additional command capabilities; the graph groups related runtime behavior rather than listing every command. Edges follow shown calls or explicit README flows; AOF replay details are documented but only partly excerpted.
Main entry points: db.rs Command operations · main.rs Connection handler · parser.rs RESP parser · encoder.rs RESP encoder
Components 11
TCP server
- TCP listener
src/main.rs - Connection handler
src/main.rs - Command router
src/main.rs
RESP protocol
- RESP parser
src/parser.rs - RESP frame
src/frame.rs - RESP encoder
src/encoder.rs
Database and persistence
- Command operations
src/db.rs - In-memory state
src/db.rs - AOF log
klyn.aof - Startup replay
src/main.rs
Other components
- Redis client
Connections 16
- Redis client → TCP listener: sends RESP
README.md - TCP listener → Connection handler: spawns handler
src/main.rs - Connection handler → RESP parser: parses request
src/main.rs - RESP parser → RESP frame: produces frames
src/parser.rs - Connection handler → Command router: routes command
src/main.rs - Command router → Command operations: invokes operations
src/main.rs - Command operations → In-memory state: reads and mutates
src/db.rs - Command operations → AOF log: appends writes
src/db.rs - Command operations → RESP encoder: encodes log entries
src/db.rs - Command operations → RESP frame: returns response frames
src/db.rs - Command router → RESP encoder: encodes response
src/main.rs - RESP encoder → RESP frame: serializes frames
src/encoder.rs - Connection handler → Redis client: writes response
README.md - AOF log → Startup replay: restores history
README.md - Startup replay → RESP parser: parses log frames
src/main.rs - Startup replay → In-memory state: rebuilds state
src/main.rs