15 Mar 2011 20:00
Re: Moving cache from object count to size
Jesus Cea <jcea <at> jcea.es>
2011-03-15 19:00:51 GMT
2011-03-15 19:00:51 GMT
On 16/01/11 22:44, Neil Schemenauer wrote: > Jesus Cea <jcea <at> jcea.es> wrote: >> I have objects 50 bytes long, and 60Kbytes long(Continue reading). I would >> suggest to change the cache code to control cache size, instead of >> object count. > > I played with this idea a little. It seems like the bookkeeping > will get pretty complicated. Iterating over all objects in the > cache to find the current size does not seem feasible, for > performance reasons. Therefore, the cache would have to keep track > of the total size as objects are added and removed. The fact that > objects are weakly referenced by the cache futher complicates > things. > > Maybe I'm missing a simple implementation but it doesn't appear to > be worth the effort, IMHO. You have the weak reference callback, for instance. It is not different to current cache object count. -- -- Jesus Cea Avion _/_/ _/_/_/ _/_/_/ jcea <at> jcea.es - http://www.jcea.es/ _/_/ _/_/ _/_/ _/_/ _/_/ jabber / xmpp:jcea <at> jabber.org _/_/ _/_/ _/_/_/_/_/ .. _/_/ _/_/ _/_/ _/_/ _/_/ "Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/ "My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/ "El amor es poner tu felicidad en la felicidad de otro" - Leibniz
. I would
>> suggest to change the cache code to control cache size, instead of
>> object count.
>
> I played with this idea a little. It seems like the bookkeeping
> will get pretty complicated. Iterating over all objects in the
> cache to find the current size does not seem feasible, for
> performance reasons. Therefore, the cache would have to keep track
> of the total size as objects are added and removed. The fact that
> objects are weakly referenced by the cache futher complicates
> things.
>
> Maybe I'm missing a simple implementation but it doesn't appear to
> be worth the effort, IMHO.
You have the weak reference callback, for instance. It is not different
to current cache object count.
RSS Feed