ApexKV: High-Performance In-Memory Cache Engine

March 18 2026 • Muhammad Taha Nasir

Project Overview

ApexKV is a production-grade, high-performance in-memory cache engine built entirely in Java as part of the Software Design and Analysis course. It eliminates the latency of repeatedly querying disk-backed databases by providing lightning-fast memory access. Unlike basic hash maps, ApexKV brings enterprise-level database features—such as dual ACID persistence (Write-Ahead Logging and Snapshots), multi-thread safety, intelligent dynamic eviction, and priority-queue expiration into a lightweight, standalone system without any external dependencies.

Situation

Modern distributed applications often suffer from significant performance bottlenecks when scaling due to slow I/O operations from traditional relational databases. A robust, low-latency caching layer is essential for modern web applications. The challenge was to engineer a standalone, highly concurrent key-value store from scratch that provides robust data integrity and resilience, without relying on massive third-party database engines, while strictly adhering to proven Software Design Patterns.

Task

The goal was to design, develop, and extensively test an enterprise-grade caching engine featuring:

  • Dynamic, hot-swappable cache eviction policies (LRU, LFU, FIFO, MRU, RANDOM).
  • Highly efficient deterministic key expiration using $O(\log N)$ TTL Scheduling.
  • Crash-resilient transactions via Dual Persistence (Snapshots and WAL).
  • Multi-protocol accessibility (REST API, CLI, and TCP Server).
  • A real-time analytics dashboard to monitor performance metrics and hot-key detection.

Actions

  • Implemented Software Design Patterns: Utilized the Factory Pattern for dynamic data types (Strings, Sets, Hashes, Binary), Strategy Pattern for runtime-swappable eviction algorithms, Observer Pattern for Pub/Sub messaging, Scheduler Pattern for background TTL cleanup, and Singleton Pattern for shared centralized states.
  • Engineered Dual Persistence: Developed an ACID-compliant storage layer employing both point-in-time Snapshots and a Write-Ahead Log (WAL) for 100% state restoration in case of crashes.
  • Built the Core Caching Engine: Engineered a highly concurrent, thread-safe memory manager capable of seamlessly handling thousands of simultaneous read/write operations without race conditions.
  • Developed Multi-Protocol Access: Built embedded HTTP/REST and TCP Socket servers, along with an interactive terminal client, enabling easy interaction from various client applications.
  • Created the Analytics Dashboard: Designed a responsive, web console providing live KPI tracking, real-time analytics, and benchmark execution.

Results

ApexKV demonstrated exceptional performance and reliability during rigorous benchmarking and validation:

  • Achieved 25,000+ Concurrent Operations per second with an average latency of ~1.8ms and a hit rate exceeding 96.4%.
  • The comprehensive CacheTestSuite continuously validated data integrity, resulting in a 100% Success Rate across all independent test vectors (CRUD, TTL, Concurrency, and Recovery).
  • Verified completely race-condition-free operation during peak multi-threaded simulations, providing a highly scalable and robust software architecture.

Tech Stack

  • Core Language: Java 17+
  • Frontend: HTML5, CSS3, Vanilla JavaScript (for Dashboard)
  • Architecture: Factory, Strategy, Observer, Scheduler, Singleton Patterns
  • Features: TCP Socket Server, Embedded HTTP Server, PriorityBlockingQueue for TTL, Write-Ahead Logging (WAL)