Skip to content

A simple cache with ttls on items based on ets and timers. Tested with property model testing.

License

Notifications You must be signed in to change notification settings

v-kat/simpler_cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimplerCache

Build Status License: MIT Hex pm hexdocs.pm

Description

A very simple cache. It uses timers for the ttl and ets for the storage. No locks are used and there is a fix to prevent thundering herd issues when the cache is warm and pre-emptively refresh the cache (it triggers in low ttl left of item situations). There is also a thundering herd fix for when the cache is cold using a sentinel key and a sleep. Mostly wrapper around ets and kept very simple by using newer apis and recent erlang improvements.

Using property model testing and property tests to verify the cache via propcheck.

Installation

available in Hex, the package can be installed by adding simpler_cache to your list of dependencies in mix.exs:

def deps do
  [
    {:simpler_cache, "~> 0.1.8"}
  ]
end
  • Sample configs
config :simpler_cache,
  cache_name: :simpler_cache_test,
  global_ttl_ms: 100_000

100 processes concurrently hitting cache on 1 key with get_or_store

iterations

runtime

About

A simple cache with ttls on items based on ets and timers. Tested with property model testing.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages