CarCache

Elixir CIModule VersionHex DocsTotal DownloadLicenseLast Updated

CLOCK with adaptive replacement (CAR) cache, based on the following paper:

CAR: Clock with Adaptive Replacement

CAR is a self tuning cache that strives to find a balance between frequently accessed items and recently accessed items.

CAR is fairly similar to ARC Adaptive Replacement Cache for which there is a good introductory explanation here: Adaptive Replacement Cache

Usage

The cache must be given a name and a max_size when started.

{:ok, _pid} = CarCache.start_link(name: :my_cache, max_size: 1_000)

After the process has started you can use it based on it's name:

> CarCache.get(:my_cache, :foo)
nil

> CarCache.insert(:my_cache, :foo, :bar)
:ok

> CarCache.get(:my_cache, :foo)
:bar