KDECore
Go to the documentation of this file.
27 #include <QtCore/QString>
28 #include <QtCore/QByteArray>
29 #include <QtCore/QCache>
31 class KSharedDataCache::Private
35 QCache<QString, QByteArray> cache;
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));
71 QByteArray *value = d->cache.object(key);
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 contains(const QString &key) const
Returns true if the cache currently contains the image for the given filename.
KSharedDataCache(const QString &cacheName, unsigned defaultCacheSize, unsigned expectedItemSize=0)
Attaches to a shared cache, creating it if necessary.
unsigned timestamp() const
void clear()
Removes all entries from the cache.
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.
EvictionPolicy evictionPolicy() const
unsigned totalSize() const
Returns the usable cache size in bytes.
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...
void setTimestamp(unsigned newTimestamp)
Sets the shared timestamp of 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...
static void deleteCache(const QString &cacheName)
Removes the underlying file from the cache.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Jan 30 2020 00:00:00 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.