Skip to content

rogeeff/code-review-exercise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

datacache

A thread-safe, header-only LRU cache for C++17.

Features

  • O(1) average-case get and put operations
  • Configurable capacity with LRU eviction
  • Thread-safe with mutex-based synchronization
  • Hit/miss rate tracking

Usage

#include <datacache/cache.h>

datacache::Cache<std::string, int> cache(1000);

cache.put("answer", 42);

auto val = cache.get("answer");  // std::optional<int>(42)

Building

mkdir build && cd build
cmake ..
make
ctest

Benchmarks

A Python reference implementation is included for performance comparison:

python3 scripts/benchmark.py

About

Code review interview exercise - Thread-safe LRU cache with TTL support

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors