From: Intransition Date: 2010-04-14T05:43:50+09:00 Subject: Re: Memoize and GC On Apr 13, 1:28 pm, Caleb Clausen wrote: > On 4/13/10, Intransition wrote: > > > will mean that @foo be GC'd when the object is GC'd, but if I do > > >   FOO = [] > > >   def foo > >     FOO[object_id] ||= something > >   end > > I have to assume that you meant FOO to be a hash... tho an array will > work here... sorta. > > But rather than either an array or hash, what if you could write: > >   FOO=Cache.new > > That is, FOO would behave mostly like a hash, but unused entries would > age out after a while. Now if only someone would invent an appropriate > Cache class. Ah, very good thought! An LRUCache would do pretty well here. Well then, that leads to me to another project. My implementation of LRUCache (lrucache gem) kind of sucks in that it only handles max size, so I am looking for a new one to replace it. Any recommendations?