Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QCache for QSharedData
overquill last edited by
I want to load some objects from a database, and I want to use lazy loading for object members.
So I implemented the members by using QSharedDataPointer, and now, while implementing the loader, stumbled upon QCache.
Is there a cache that does only free elements that have their reference count decreased to zero (aside from their reference in the cache), and holds all other objects (as their data is in use in the memory anyway)?
I think this is a very common scenario when using sql-databases, but I did not find any ready-to-use solution in the forums. Do I have to implement this by myself including reference counting, or can I at least somehow overload a QShared*-class to insert or remove itself from the associated cache?
I guess I was looking for QWeakPointer... problem solved.