0.0
No commit activity in last 3 years
No release in over 3 years
Reusable module to extend named memoized blocks with an expiration time.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.7
~> 10.0
 Project Readme

MemoizeTtl

Simple memoize with an expiration time (time-to-live).

MemoizeTtl is not a key based storage. MemoizeTtl is an instance variable storage system backed by a ruby macro that writes getter/generator methods with an expire check pattern for you.

Use Cases

  • In process, decentralized cache
  • Volatile data debouncing
  • Cache with-in cache. Self-expiring memoized values are serializable.

Installation

Add this line to your application's Gemfile:

gem 'memoize_ttl'

And then execute:

$ bundle

Or install it yourself as:

$ gem install memoize_ttl

Usage

This example re-evaluates fish if its called later than 5 seconds apart.

class Taco
 extend MemoizeTtl
 memoize_ttl :fish, 5 do
   puts "eval"
   "salmon"
 end
end