Simple lru cache?
TeaAndBikkie
teaandbikkie at aol.com
Sat Oct 5 11:06:52 EDT 2002
>From: Ype Kingma ykingma at accessforall.nl
>I'd expect in the order of 10000 items cached of which:
>20% would be used around 4 times,
>20% around 3 times,
>20% around 2 times,
>40% used once only.
>
Perhaps you could improve the performance of the LRU cache by adding a small
complexity to preferentially keep those items most reused, in combination with
recent items.
Say keep a count of how many hits for each item, then when removing items from
the cache, keep an older more-used item in preference to a newer one-hit-wonder
item (unless the older one is older than an agreed expiry time, to prevent a
senile cache from piling up). This might prevent the cache getting filled with
recent stuff that is not needed again...
I suspect that generally this has some disadvantages, but in your case it might
work well.
-- Misha
More information about the Python-list
mailing list