27 #include <QtCore/QString>
28 #include <QtCore/QByteArray>
29 #include <QtCore/QCache>
31 class KSharedDataCache::Private
39 unsigned defaultCacheSize,
40 unsigned expectedItemSize)
43 d->cache.setMaxCost(defaultCacheSize);
46 Q_UNUSED(expectedItemSize);
56 return d->evictionPolicy;
61 d->evictionPolicy = newPolicy;
66 return d->cache.insert(key,
new QByteArray(data));
94 return d->cache.contains(key);
99 return static_cast<unsigned>(d->cache.maxCost());
104 if (d->cache.totalCost() < d->cache.maxCost()) {
105 return static_cast<unsigned>(d->cache.maxCost() - d->cache.totalCost());
bool insert(const QString &key, const QByteArray &data)
Attempts to insert the entry data into the shared cache, named by key, and returns true only if succe...
unsigned totalSize() const
Returns the usable cache size in bytes.
void setTimestamp(unsigned newTimestamp)
Sets the shared timestamp of the cache.
static void deleteCache(const QString &cacheName)
Removes the underlying file from the cache.
bool find(const QString &key, QByteArray *destination) const
Returns the data in the cache named by key (even if it's some other process's data named with the sam...
void clear()
Removes all entries from the cache.
unsigned timestamp() const
KSharedDataCache(const QString &cacheName, unsigned defaultCacheSize, unsigned expectedItemSize=0)
Attaches to a shared cache, creating it if necessary.
EvictionPolicy evictionPolicy() const
unsigned freeSize() const
Returns the amount of free space in the cache, in bytes.
void setEvictionPolicy(EvictionPolicy newPolicy)
Sets the entry removal policy for the shared cache to newPolicy.
bool contains(const QString &key) const
Returns true if the cache currently contains the image for the given filename.