FileCache is pretty good for keeping binary data like images.
But imagine we have some structured data and we need to access only some fields of this data.
Yes it's about vcards where we need binary photo which is usually kept as base64 in vcard xml. So to extract it, it's first necessary to parse xml and then decode base64. And if we need it quite often like for example in case rendering roster items, it starts consuming tangible CPU resources. Yes currently Psi caches is twice to handle this case, but this way we consume memory more than needed.
As a solution for this we can invent something in FileCacheItem or on top of it and also modify FileCache itself to have serializable items, which on access won't need any additional resource-consuming work. In other words in some cases we don't want to manipulate byte arrays but instead we want to manipulate some structural data. And for this we need items which can be serialized to bytearrray and deserialized back.
Some idea about implementation:
FileCacheItem already has flags. We can add another flag Serializable.
Then we need FileCacheSerialiableItem interface have QByteArray serialize() const and bool deserialize(const QByteArray &) methods and also virtual destructor.
FileCacheItem::_data can be added to a union with FileCacheSerialiableItem*, and the flag above will determine what we work with.
FileCache is pretty good for keeping binary data like images. But imagine we have some structured data and we need to access only some fields of this data.
Yes it's about vcards where we need binary photo which is usually kept as base64 in vcard xml. So to extract it, it's first necessary to parse xml and then decode base64. And if we need it quite often like for example in case rendering roster items, it starts consuming tangible CPU resources. Yes currently Psi caches is twice to handle this case, but this way we consume memory more than needed.
As a solution for this we can invent something in FileCacheItem or on top of it and also modify FileCache itself to have serializable items, which on access won't need any additional resource-consuming work. In other words in some cases we don't want to manipulate byte arrays but instead we want to manipulate some structural data. And for this we need items which can be serialized to bytearrray and deserialized back.
Some idea about implementation:
FileCacheItem
already has flags. We can add another flagSerializable
. Then we needFileCacheSerialiableItem
interface haveQByteArray serialize() const
andbool deserialize(const QByteArray &)
methods and also virtual destructor.FileCacheItem::_data
can be added to a union withFileCacheSerialiableItem*
, and the flag above will determine what we work with.