Project

memoize

0.02
No commit activity in last 3 years
No release in over 3 years
The memoize library allows you to cache methods for faster lookup. Cached results can either be stored in memory (the default) or to a file.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 2.0.2
 Project Readme
= DEPRECATION WARNING
  Please do not use this gem. It has long been surpassed by other, better
  memoization gems like memoizable and memoist.

= Description
  A method that speeds methods up at the cost of memory (or disk space).
   
= Installation
  gem install memoize

= Synopsis
  require 'memoize'
  include Memoize

  # Inefficient fibonacci method
  def fib(n)
    return n if n < 2
    fib(n-1) + fib(n-2)
  end

  fib(100) # Slow

  memoize(:fib)
  fib(100) # Fast
   
  # Or store the cache to a file for later use
  memoize(:fib, "fib.cache")
  fib(100) # Fast

= Constants
Memoize::MEMOIZE_VERSION
   Returns the version of this package as a String.

= Methods
Memoize#memoize(method, file=nil)
   Takes a +method+ (symbol) and caches the results of +method+ in a hash
   table. If you call +method+ again with the same arguments, memoize gives
   you the value from the table instead of letting the method compute the
   value again.
   
   If +file+ is provided, the results are cached to that file.  Note that
   this uses Marshal internally.  Beware of changes in the Marshal format
   should you happen to upgrade.

   Returns the cache, which you can inspect or manipulate directly if you are
   so inclined.

= Acknowledgements
  Code borrowed from Nobu Nakada (ruby-talk:155159).
  Code borrowed from Ara Howard (ruby-talk:173428).
  Code borrowed from Andrew Johnson (http://tinyurl.com/8ymx8)
  Ideas taken from Brian Buckley and Sean O'Halpin.
  Tiny URL provided for Andrew Johnson because I could not find the ruby-talk
  reference. The gateway may have been broken at the time.

= Alternatives
  * memoist by Joshua Peek et al.
  * memoizable from James Edward Gray
  * simple_memoize from Jack Canty

  Running "gem search -r memoize" will list more alternatives.
   
== Known Issues
  This library is deprecated. I will no longer support it, and will
  eventually yank it from the gem index.

== License
  Artistic 2.0
   
== Warranty
  This package is provided "as is" and without any express or
  implied warranties, including, without limitation, the implied
  warranties of merchantability and fitness for a particular purpose.

== Copyright
  (C) 2005-2014 Daniel J. Berger
  All Rights Reserved

= Author
  Daniel J. Berger