TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 229 subscribers
Post #25823 8
VeloCache: A high-performance, Redis-compatible in-memory key-value store built from scratch in C++20 using kqueue and async I/O

Hi everyone,

I wanted to share a systems project I’ve been building solo: **VeloCache**. It’s a high-performance, Redis-compatible in-memory key-value store written from scratch in C++20, specifically optimized for macOS/BSD using native `kqueue`.

# Key Technical Architecture:

* **Asynchronous Networking:** A single `kqueue` event loop handles non-blocking TCP sockets, supporting pipelining and fragmented frames without spawning a thread per client.
* **Non-blocking Storage Thread:** The core storage engine, AOF logging, and replication updates are handled by a dedicated FIFO `BackgroundWorker` thread. Communication between the network loop and storage is done via a non-blocking `socketpair`.
* **Efficient TTL Indexing:** Deadlines are tracked via a `std::multimap<std::int64_t, std::string>`, ordered by absolute deadline. Erasing by iterator prevents O(N) database scans, giving amortized O(1) performance.
* **Durability:** Implements AOF persistence with 64-bit FNV-1a checksums and atomic snapshot installations (`mkstemp` \+ `rename`).
* **Asynchronous Replication:** Master/slave topology supporting `SYNC` streams, sequence validation, and explicit loading states.

I also wrote a zero-dependency TypeScript client using only the native Node.js `net` module for integration testing.

The project puts a lot of focus on POSIX resource boundaries, backpressure control (128 MiB / 1024 operations max queue budget), and edge-case test suites (covering everything from mid-flight replication drops to simulated slow-disk `fsync` injection via an interposition library).

The repository has a fully configured macOS CI pipeline. I would absolutely love to get some **brutal code review**, architecture critiques, or tips on performance optimization from the systems engineers here!

**Repo Link:** [https://github.com/geamnegru/VeloCache](https://github.com/geamnegru/VeloCache)

Thanks for reading!

https://redd.it/1x0kw4o
@r_cpp
GitHub GitHub - geamnegru/VeloCache: A high-performance, Redis-compatible in-memory key-value store built solo from scratch in C++20 using… A high-performance, Redis-compatible in-memory key-value store built solo from scratch in C++20 using kqueue for asynchronous I/O and custom RESP parsing. - geamnegru/VeloCache
More from @r_cpp
  1. Oct 8, 2026Profiles for simplicity and guarantees - Bjarne Stroustrup - CppCon 2026 https://youtu.be/…
  2. Oct 8, 2026How to Fix autoconf-style Configuration Probing https://build2.org/blog/fix-autoconf.xhtml…
  3. Oct 8, 2026owl – a header-only C++23 HTTP framework where route patterns and handler extractors are c…
  4. Oct 8, 2026Removed by Reddit Removed by Reddit on account of violating the [content policy. ] https:/…
  5. Oct 8, 2026Is there a way to search across all P and N papers throughout standardization history? It…
  6. Oct 8, 2026CppCast Episode 412 : Safety and Interoperability with Rust and C++ https://cppcast.com/sa…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →