LeechCraft 0.6.70-17609-g3dde4097dd
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
LC::Util::NetworkDiskCache Class Reference

A thread-safe garbage-collected network disk cache. More...

#include "networkdiskcache.h"

Inheritance diagram for LC::Util::NetworkDiskCache:
Collaboration diagram for LC::Util::NetworkDiskCache:

Public Member Functions

 NetworkDiskCache (const QString &subpath, QObject *parent=nullptr)
 Constructs the new disk cache.
qint64 cacheSize () const override
 Reimplemented from QNetworkDiskCache.
QIODevice * data (const QUrl &url) override
 Reimplemented from QNetworkDiskCache.
void insert (QIODevice *device) override
 Reimplemented from QNetworkDiskCache.
QNetworkCacheMetaData metaData (const QUrl &url) override
 Reimplemented from QNetworkDiskCache.
QIODevice * prepare (const QNetworkCacheMetaData &) override
 Reimplemented from QNetworkDiskCache.
bool remove (const QUrl &url) override
 Reimplemented from QNetworkDiskCache.
void updateMetaData (const QNetworkCacheMetaData &metaData) override
 Reimplemented from QNetworkDiskCache.

Protected Member Functions

qint64 expire () override
 Reimplemented from QNetworkDiskCache.

Detailed Description

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 32 of file networkdiskcache.h.

Constructor & Destructor Documentation

◆ NetworkDiskCache()

LC::Util::NetworkDiskCache::NetworkDiskCache ( const QString & subpath,
QObject * parent = nullptr )
explicit

Constructs the new disk cache.

The cache uses a subdirectory subpath in the network directory of the user cache location.

Parameters
[in]subpathThe subpath in cache user location.
[in]parentThe parent object of this cache.
See also
GetUserDir(), UserDir::Cache.

Definition at line 27 of file networkdiskcache.cpp.

Member Function Documentation

◆ cacheSize()

qint64 LC::Util::NetworkDiskCache::cacheSize ( ) const
override

Reimplemented from QNetworkDiskCache.

Definition at line 35 of file networkdiskcache.cpp.

◆ data()

QIODevice * LC::Util::NetworkDiskCache::data ( const QUrl & url)
override

Reimplemented from QNetworkDiskCache.

Definition at line 40 of file networkdiskcache.cpp.

◆ expire()

qint64 LC::Util::NetworkDiskCache::expire ( )
overrideprotected

Reimplemented from QNetworkDiskCache.

Definition at line 91 of file networkdiskcache.cpp.

References LC::Util::NetworkDiskCacheGC::Instance().

Here is the call graph for this function:

◆ insert()

void LC::Util::NetworkDiskCache::insert ( QIODevice * device)
override

Reimplemented from QNetworkDiskCache.

Definition at line 46 of file networkdiskcache.cpp.

◆ metaData()

QNetworkCacheMetaData LC::Util::NetworkDiskCache::metaData ( const QUrl & url)
override

Reimplemented from QNetworkDiskCache.

Definition at line 62 of file networkdiskcache.cpp.

Referenced by updateMetaData().

Here is the caller graph for this function:

◆ prepare()

QIODevice * LC::Util::NetworkDiskCache::prepare ( const QNetworkCacheMetaData & metadata)
override

Reimplemented from QNetworkDiskCache.

Definition at line 68 of file networkdiskcache.cpp.

◆ remove()

bool LC::Util::NetworkDiskCache::remove ( const QUrl & url)
override

Reimplemented from QNetworkDiskCache.

Definition at line 77 of file networkdiskcache.cpp.

◆ updateMetaData()

void LC::Util::NetworkDiskCache::updateMetaData ( const QNetworkCacheMetaData & metaData)
override

Reimplemented from QNetworkDiskCache.

Definition at line 85 of file networkdiskcache.cpp.

References metaData().

Here is the call graph for this function:

The documentation for this class was generated from the following files:
  • /home/abuild/rpmbuild/BUILD/leechcraft-doc-0.6.70+git.17609.g3dde4097dd-build/leechcraft-0.6.70-17609-g3dde4097dd/src/util/network/networkdiskcache.h
  • /home/abuild/rpmbuild/BUILD/leechcraft-doc-0.6.70+git.17609.g3dde4097dd-build/leechcraft-0.6.70-17609-g3dde4097dd/src/util/network/networkdiskcache.cpp