[Interest] Qt based LRU container?

André Somers andre at familiesomers.nl
Sun Oct 20 08:27:15 CEST 2013


I imagine this did not surface before, is because the need to get notified seems quite rare to me. Usually, a cache is store-and-forget.

However, to solve your problem, I would create a thin wrapper object around the value to store for the notification part, and store that in your cache. Or, re-create QCache. It's really not that hard to do. I did it recently because I needed a value based cache instead if a pointer based one...


Verstuurd vanaf mijn iPhone

Op 19 okt. 2013 om 21:35 heeft Mark <markg85 at gmail.com> het volgende geschreven:

On Sat, Oct 19, 2013 at 9:20 PM, Richard Moore <rich at kde.org> wrote:
On 19 October 2013 18:43, Mark <markg85 at gmail.com> wrote:
Does anyone know of an LRU based container for Qt? I'm specifically
looking for an implementation that notifies me when something gets
removed due to LRU kicking in. QCache would be nearly OK for my needs,
but it doesn't notify me when something drops out due to LRU kicking

If you need to know when something is evicted then it's not really
acting as just a cache. That said, you could do it by making the
object in the cache inform you in its destructor.


hmm, that could work. Never thought about using the destructor.
On the other hand, i would get into trouble when the object isn't only
in the cache but also in other places. Then a destruction signal might
not necessarily mean that it's removed from the cache.

> Is there now "QLru" made in recent years? I mean, i can imagine the

need for an LRU to be quite high in some Qt areas so i'm quite
surprised that there doesn't seem to be any of it. Embedded comes to
Interest mailing list
Interest at qt-project.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131020/2031e8cb/attachment.html>

More information about the Interest mailing list