Skip to content

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

License

Notifications You must be signed in to change notification settings

educabilia/memmo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages