No commit activity in last 3 years
No release in over 3 years
Store a single value in memory with expiration
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Store a single value in memory with expiration

  • fast & simple alternative to things like ActiveSupport::Cache::MemoryStore
  • does not cache nil
  • uses Process::CLOCK_MONOTONIC for fast time math

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
Build Status