From: Robert Klemme Date: 2004-09-28T21:34:20+09:00 Subject: Re: [ANN] ncache 0.9 "George Moschovitis" schrieb im Newsbeitrag news:1096373667.801902.153440@h37g2000oda.googlegroups.com... > > What do you mean by complexity? Storing a single linked list element > is > > not really something I'd call "complex". > > Hmm, I probably didnt understand your suggestion correctly, can you > elaborate please? I am very intereseted in your idea. class LruCache ListItem = Struct.new(:obj,:prev,:next) private def create_list_item begin return @spare || ListItem.new ensure @spare = nil end end def return_list_item(li) @spare ||= li end end Then use #create_list_item and #return_list_item wherever you create or release ListItems. > > *I* would not find this natural. If I were using a LRU cache I'd > only > > expect to have to provide keys that satisfy the same conditions as > Hash > > Well I find natural that a Cache only accepts Cacheable objects (ie > objects that extend the LRUCache::Item). Like a render that accepts > renderable objects. As you say we are free to dissagree :-) > best regards, Although there is some truth in this, a LRUCache is something more general than a renderer - in fact it comes close to Hash IMHO. So there should be less requirements on container instances than for a renderer. Regards robert