![]() |
LeechCraft
%{LEECHCRAFT_VERSION}
Modular cross-platform feature rich live environment.
|
A thread-safe garbage-collected network disk cache. More...
#include "networkdiskcache.h"
Public Slots | |
void | collectGarbage () |
Runs the garbage collector. More... | |
Public Member Functions | |
NetworkDiskCache (const QString &subpath, QObject *parent=0) | |
Constructs the new disk cache. More... | |
~NetworkDiskCache () | |
Destroys the cache. More... | |
virtual qint64 | cacheSize () const |
Reimplemented from QNetworkDiskCache. More... | |
virtual QIODevice * | data (const QUrl &url) |
Reimplemented from QNetworkDiskCache. More... | |
virtual void | insert (QIODevice *device) |
Reimplemented from QNetworkDiskCache. More... | |
virtual QNetworkCacheMetaData | metaData (const QUrl &url) |
Reimplemented from QNetworkDiskCache. More... | |
virtual QIODevice * | prepare (const QNetworkCacheMetaData &) |
Reimplemented from QNetworkDiskCache. More... | |
virtual bool | remove (const QUrl &url) |
Reimplemented from QNetworkDiskCache. More... | |
virtual void | updateMetaData (const QNetworkCacheMetaData &metaData) |
Reimplemented from QNetworkDiskCache. More... | |
Protected Member Functions | |
virtual qint64 | expire () |
Reimplemented from QNetworkDiskCache. More... | |
A thread-safe garbage-collected network disk cache.
This class is thread-safe unlike the original QNetworkDiskCache, thus it can be used from multiple threads simultaneously.
Also, old cache data is automatically removed from the cache in a background thread without blocking. The garbage collection can be also triggered manually via the collectGarbage() slot.
The garbage is collected until cache takes 90% of its maximum size.
Definition at line 57 of file networkdiskcache.h.
LeechCraft::Util::NetworkDiskCache::NetworkDiskCache | ( | const QString & | subpath, |
QObject * | parent = 0 |
||
) |
Constructs the new disk cache.
The cache uses a subdirectory subpath in the network directory of the user cache location.
[in] | subpath | The subpath in cache user location. |
[in] | parent | The parent object of this cache. |
Definition at line 45 of file networkdiskcache.cpp.
References LeechCraft::Util::Cache, collectGarbage(), and LeechCraft::Util::GetUserDir().
LeechCraft::Util::NetworkDiskCache::~NetworkDiskCache | ( | ) |
Destroys the cache.
Destroys the cache object, possibly blocking until the garbage collector finishes if it is running.
Definition at line 60 of file networkdiskcache.cpp.
|
virtual |
Reimplemented from QNetworkDiskCache.
Definition at line 66 of file networkdiskcache.cpp.
|
slot |
Runs the garbage collector.
This function initiates garbage collection in a background thread and returns immediately.
If a collector is already running, this function does nothing.
Definition at line 179 of file networkdiskcache.cpp.
Referenced by expire(), and NetworkDiskCache().
|
virtual |
Reimplemented from QNetworkDiskCache.
Definition at line 71 of file networkdiskcache.cpp.
|
protectedvirtual |
Reimplemented from QNetworkDiskCache.
Runs the garbage collector if required.
Definition at line 122 of file networkdiskcache.cpp.
References collectGarbage().
|
virtual |
Reimplemented from QNetworkDiskCache.
Definition at line 77 of file networkdiskcache.cpp.
|
virtual |
Reimplemented from QNetworkDiskCache.
Definition at line 93 of file networkdiskcache.cpp.
|
virtual |
Reimplemented from QNetworkDiskCache.
Definition at line 99 of file networkdiskcache.cpp.
|
virtual |
Reimplemented from QNetworkDiskCache.
Definition at line 108 of file networkdiskcache.cpp.
|
virtual |
Reimplemented from QNetworkDiskCache.
Definition at line 116 of file networkdiskcache.cpp.