Project

memoist2

0.01
No commit activity in last 3 years
No release in over 3 years
Really simple memoization for ruby 2.0
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
>= 0
 Project Readme

memoist2

Build Status

Simple Memoization for Ruby 2.0+.

Differences between Memoist & Memoist2

Unlike Memoist, this is not a drop-in replacement for old ActiveSupport::Memoizable. Memoist will still work just fine for that if you're using Ruby 2.0+. This project, on the other hand, is just me playing using Module#prepend which makes this stuff very simple.

Memoist

  • Works on all Rubies.
  • Is quite complicated.
  • Has the exact same api as ActiveSupport::Memoizable.

Memoist2

  • Only works on Ruby >= 2.0.0.
  • Is deliberately much simpler.
  • Has a slightly different API that could totally change.

Example

Memoize an instance method

class Foo
  include Memoist2

  def bar
    sleep 1 && 2**10
  end
  memoize :bar
end

Memoize a class method

class Foo
  include Memoist2

  def self.bar
    # something expensive
  end
  memoize_class_method :bar
end

Licence

Licensed under the MIT licence.

See the file LICENCE.