From: Robert Klemme Date: 2010-04-15T16:16:15+09:00 Subject: Re: Memoize and GC 2010/4/14 Intransition : > > On Apr 14, 7:02 am, Robert Klemme wrote: > >> What else do you want to handle?  My implementation [1] does also only >> consider size but I have also seen implementations that consider >> insertion or access time.  Personally I dislike those solutions >> because they might throw away stuff too early and make the >> implementation more complex.  The main point (resource control) is >> already achieved by limiting the size of a LRU map. > > Fair enough, I just thought it would be nice to have the *option* of a > time-based cache. Definitively! But this would be a different beast for me. One might be able to implement this by using a LRUHash or by inheriting from it. But I would not combine that in a single class. Another option could be to have a modular approach where the container gets a DeletionPolicy that is responsible for deciding when or what to delete. The interface could look like interface DeletionPolicy def insert(key,val) def remove(key, val) def access(key, val) def next_delete # yields key end Just a quick hack though withou Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/