How theproject24/titan_kv works
Titan KV is a Redis-compatible in-memory key-value server. A client sends RESP (or simple text) over TCP; the server parses and dispatches commands, then returns RESP results. The engine supports strings, lists, hashes, sets, TTLs, key scans, and cross-shard operations; pub/sub and monitoring provide separate event-stream features. Startup restores state from AOF, while background workers persist writes, expire keys, and compact the log. The README documents these capabilities; sampled source excerpts are partial, so uncertain command-level wiring is omitted.
Main entry points: main.rs Startup orchestrator · server.rs TCP command server · engine.rs Sharded store · database.aof database.aof
Components 15
Client and protocol
- TCP command server
src/server.rs - RESP parser
src/protocol.rs
Server runtime
- Runtime config
src/config.rs - Startup orchestrator
src/main.rs - Logging
src/logger.rs
Database features
- Sharded store
src/engine.rs - Pub/sub broker
src/pubsub.rs - Monitor stream
src/engine.rs
AOF durability
- AOF replay
src/main.rs - AOF write queue
src/engine.rs - AOF writer
src/main.rs - TTL sweeper
src/main.rs - AOF compactor
src/main.rs - database.aof
database.aof
Other components
- Redis clients
Connections 23
- Redis clients → TCP command server: send TCP
- TCP command server → Redis clients: return RESP
- TCP command server → RESP parser: read and parse
- TCP command server → Sharded store: execute commands
- TCP command server → Pub/sub broker: publish and subscribe
- TCP command server → Monitor stream: stream activity
- Startup orchestrator → Runtime config: parse settings
- Startup orchestrator → TCP command server: launch listener
- Startup orchestrator → Sharded store: initialize store
- Startup orchestrator → AOF replay: restore state
- AOF replay → database.aof: read log
- AOF replay → RESP parser: tokenize commands
- AOF replay → Sharded store: rebuild state
- Sharded store → AOF write queue: enqueue writes
- AOF write queue → AOF writer: deliver log entries
- AOF writer → database.aof: append writes
- Startup orchestrator → TTL sweeper: start worker
- TTL sweeper → Sharded store: scan and delete
- TTL sweeper → database.aof: append deletions
- Startup orchestrator → AOF compactor: start worker
- AOF compactor → Sharded store: read current state
- AOF compactor → database.aof: replace compacted log
- Startup orchestrator → Logging: log lifecycle