memecache
A minimal, zero-dependency, in-memory caching library in C++ — built for understanding, not for frameworks.
Overview
A minimal, thread-safe caching library built entirely in C++ using the Standard Template Library — no external dependencies, no bloat. Supports multiple cache eviction policies and can extend custom eviction policies through a clean abstract interface.
Eviction Policies
The library implements common cache replacement strategies:
- FIFO — First-In/First-Out
- LIFO — Last-In/First-Out
- LRU — Least Recently Used
An exhaustive list of cache algorithms for reference: Wikipedia — Cache Algorithms.
Thread Safety
The library is thread-safe by design — multiple threads can perform concurrent
PutGetCustom Policies
To implement a custom eviction policy, include the
cache_policy.hpp- — handles element insertion
Insert(const Key& key) - — handles cache hit / access
Touch(const Key& key) - — handles deletion
Erase(const Key& key) - — returns the key to evict
ReplacementCandidate()
The design prioritized correctness and simplicity over feature count. Every line of code has a reason to exist — a deliberate exercise in systems-level thinking: understanding memory layout, cache coherence implications, and the cost of abstraction in performance-critical code.