Memmo is a small library for creating key-based, in-memory caches in Ruby.
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
CHANGELOG
README.md
UNLICENSE
memmo.gemspec
rakefile

README.md

Memmo

Build Status Code Climate

Memmo is a small library for creating key-based, in-memory caches in Ruby.

It features thread safety and TTLs.

Usage

require "memmo"

$memmo = Memmo.new

$memmo.register(:popular_posts, ttl: 60) do
  # Somewhat expensive query
  Post.find(...)
end

# This call will trigger a miss and will run our expensive query.
$memmo[:popular_posts].each do |post|
  puts(post)
end

# This call will be fast for the next 60 seconds.
$memmo[:popular_posts]

Test environments

It's common to avoid caches when testing your application. For this purpose you can disable Memmo entirely:

require "test/unit"

Memmo.enabled = false

License

See UNLICENSE. With love, from Educabilia.