PDA

View Full Version : QCache serialization



Flakes
9th January 2011, 20:28
Hello,

I use QCache to keep frequently used images in memory, these images are generated with user interaction. When cache size is exceeded then old (not used for long time) images will be deleted - that is perfect for my needs. I need to be able to save the cache to file and restore it when application restarted next time. I can convert QCache to QMap and write it to disk through QDataStream, but then I loose information of frequently (recently) accessed objects. How can I preserve this information? Or is there a way to serialize QCache?

wysota
9th January 2011, 21:42
QCache doesn't expose such information especially that when you dump the cache, you need to read all its keys which makes the order useless (as the order becomes the order of which you dump the data). In general QCache should never be saved to disk, that's only a quick access cache, not a persistent one. It might be easier to implement your own cache if you really need something like that.

Flakes
10th January 2011, 17:44
I will do my own implementation then. Thanks.