Fast, Simple, & Threadsafe Ruby In-Memory Store with expiration
- Fast (using Process::CLOCK_MONOTONIC)
- Simple
- Threadsafe
- Can cache nil
gem install expiring_memory_store
store = ExpiringMemoryStore.new
store.set :a, 1, expires_in: 4
store.get :a # -> 1
store.get :b # -> nil
store.add :a, 2, expires_in: 4 # -> false
store.fetch(:a) { 1 } # -> 1
store.cleanup # remove all expired entries
Michael Grosser
michael@grosser.it
License: MIT