From: Brian Buckley Date: 2006-02-01T12:32:57+09:00 Subject: memoize to a file ------=_Part_19822_26300124.1138764763824 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello all, Using Memoize gem 1.2.0, memoizing TO a file appears to be working for me but subsequently reading that file (say, by rerunning the same script) appears NOT to be working (the fib(n) calls are being run again). Inspecting the Memoize module I changed the line cache =3D Hash.new.update(Marshal.load(File.read(file))) rescue { } to cache =3D Hash.new.update(Marshal.load(File.read(file))) and it instead of silently failing I now see the error message: "in `load': marshal data too short (ArgumentError)" My questions: 1 What is causing this error? (possibly Windows related?) 2 What is the purpose of the rescue{} suppressing the error info in the first place? 3 Instead of using Marshall would using yaml be a reasonable alternative? (I am thinking of readability of the cache file and also capability to pre-populate it) Thanks. -- Brian Buckley ------------------------------------------ require 'memoize' include Memoize def fib(n) puts "running... n is #{n}" return n if n < 2 fib(n-1) + fib(n-2) end h =3D memoize(:fib,"fib.cache") puts fib(10) ------=_Part_19822_26300124.1138764763824--