From: Brian Buckley Date: 2006-02-01T21:59:30+09:00 Subject: Re: memoize to a file ------=_Part_23877_23052295.1138798754130 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline > > 1 What is causing this error? (possibly Windows related?) > > IIRC File.read(file) doesn't open the file in binary mode; try > File.open(file, "rb"){|f| f.read} Perfect. Changing cache =3D Hash.new.update(Marshal.load(File.read(file))) rescue { } to cache =3D Hash.new.update(Marshal.load(File.open(file, "rb"){|f| f.read})) rescue { } and it works. Should this edit go into the gem (Daniel if you're listening)? > 2 What is the purpose of the rescue{} suppressing the error info in the > > first place? > > setting cache to {} if Marshal.load fails for some reason (e.g. a major > change in the Marshal format across Ruby versions). > Got it. The error supression here is just about always the correct way to handle the situation. As for editing the cache, you can always do > File.open("cache.yaml", "w") do |out| > YAML.dump(Marshal.load(File.open("cache", "rb"){|f| f.read}), out) > end Ahhh. Populate that Marshal formatted file using YAML. Good thought. ------=_Part_23877_23052295.1138798754130--