Store a single value in memory with expiration
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
Gemfile
Gemfile.lock
Rakefile
Readme.md
VERSION
mini_memory_store.gemspec

Readme.md

Store a single value in memory with expiration

Install

gem install mini_memory_store

Usage

# use it to cache results
class Foo
  def expensive_stuff
    memory_store.cache { ..something expensive.. }
  end

  private

  def memory_store
    @memory_store ||= MiniMemoryStore.new(expires_in: 30)
  end
end

store = MiniMemoryStore.new
store.set 1
store.get == 1
store.cache { 2 } == 1
store.clear
store.cache { 2 } == 2

Author

Michael Grosser
michael@grosser.it
License: MIT