[Interest] Qt based LRU container?
Till Oliver Knoll
till.oliver.knoll at gmail.com
Sun Oct 20 10:15:11 CEST 2013
Am 19.10.2013 um 21:20 schrieb Richard Moore <rich at kde.org>:
> 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.
Just for completeness sake: in case the objects happen to be derived from QObject then you could connect to the signal QObject::destroyed in order to get notified about their transition into digital eternity.
However that still would not solve the problem of knowing whether the object was or was not in the cache at the time of its destruction.
Unless off course you can guarantee that, e.g. by providing a "proxy cache object" which can (is supposed to) only exist as an object in the cache and holds a reference to the actual data (and also "owns" that data, i.e. that data would get removed by the proxy upon removal from the cache, too).
I think that is what André proposed as well, I think.
Gsändet vo mim iPhone (Swiss-German ;))
More information about the Interest