LRUCache - a simple least recently used cache

renoX renosky at free.fr
Sun Nov 4 00:11:43 PDT 2007


Charles D Hixson a écrit :
> In the hopes that someone find this useful:
> http://www.prowiki.org/wiki4d/wiki.cgi?CharlesHixson
> 
> This particular version presumes D2.x code, but I think the adjustments 
> are trivial for D1.x.

I think that there is a flaw in your code: the access counter is a 
ushort (16bit value) and is incremented each time you access an element 
in the cache: it can overflow quickly and will wrap around..

This means that recently used elements could have a _nodeId smaller than 
nodes used less recently, which means that the overflow handling code 
will drop the wrong elements..

This may not be the case in your usage, but this is either a bug or at 
least a pretty big restriction in the usage which should be clearly 
indicated.


Regards,
renoX



More information about the Digitalmars-d-announce mailing list