47
CherryDB is a lightweight, custom in-memory key-value database built from the ground up in Java to match the core features of the Redis engine. Built with full compatibility for the Redis Serialization Protocol (RESP2), the database parses and handles commands like SET, GET, DEL, EXISTS, EXPIRE, TTL, PING, and ECHO directly from standard client terminals.
To handle high-throughput client traffic, the networking layer utilizes Java Socket programming integrated with a `CachedThreadPool` executor to handle concurrent TCP connections with minimal latency. Data integrity is maintained via a thread-safe, lock-free `ConcurrentHashMap` engine.
For memory efficiency, CherryDB employs a dual-strategy key expiration mechanism: passive (lazy) cleanup during read queries and an active background daemon thread that sweeps expired keys every second. Write durability is fully guaranteed through an Append-Only File (AOF) persistence engine that continuously logs state-mutating commands and replays them on system startup to recover state. The entire database is containerized with Docker, facilitating immediate deployment and testing via `redis-cli`.
Built with