[Qt-interest] Problem using QCache

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Tue Jul 20 18:12:05 CEST 2010


> On first sight: yes, that would be expected IMHO. Page 5 was inserted
> after page 4 has been accessed. Hence, page 5 is 'younger' than page 4,
> and thus is page 4 the prime candidate for deletion. I think you can
> avoid that by simply accessing the currently displayed page again after
> inserting surrounding pages.

Yes, I suspect the same. So I need to keep the objects "hot" in the cache :)

Though I think I need to access the pages _before_ inserting the new
page. So in my case, I'll access 3 and 4 (not 5) and then insert 2.
This should evict 5 out of the cache.

I've tried this and it's working. Thanks.

> What I am wondering though: why do you bother with using QCache at all?
> The scheme is so simple, and the number of pages so low, that I'd say it
> would be trival to implement yourself in your page fetching object.

Well, I chose QCache since I did not have to bother about managing the
pages being cached. They hold more resources than explained in my
example (did that to keep the explanation uncomplicated). I simply put
the latest stuff thats needed and the rest of the pages (and the
associated resources they hold) will be deleted by the cache. Also, i
don't need to implement any book-keeping logic to know which page to
remove and which one to retain.

Though, if QCache did not work, I would implementing a "sliding
window" on my own :)

-mandeep

>
> André
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>




More information about the Qt-interest-old mailing list