A custom network cache implementation for RestLink.
More...
#include <cache.h>
Inherits QAbstractNetworkCache.
|
| | Cache (QObject *parent=nullptr) |
| |
| | ~Cache () |
| | Destructor for the Cache class.
|
| |
| qint64 | maxCacheSize () const |
| | Returns the maximum allowed cache size.
|
| |
| Q_SLOT void | setMaxCacheSize (qint64 size) |
| | Sets the maximum cache size.
|
| |
| Q_SIGNAL void | maxCacheSizeChanged (qint64 size) |
| |
| QNetworkCacheMetaData | metaData (const QUrl &url) override |
| | Retrieves the metadata for a given URL.
|
| |
| void | updateMetaData (const QNetworkCacheMetaData &metaData) override |
| | Updates the cache metadata with the provided data.
|
| |
| QIODevice * | data (const QUrl &url) override |
| | Retrieves the cached data for a given URL.
|
| |
| bool | remove (const QUrl &url) override |
| | Removes the cached data for a given URL.
|
| |
| qint64 | cacheSize () const override |
| | Returns the total size of the cache.
|
| |
| QIODevice * | prepare (const QNetworkCacheMetaData &metaData) override |
| | Prepares a QIODevice to store data in the cache.
|
| |
| void | insert (QIODevice *device) override |
| | Inserts data into the cache.
|
| |
| Q_SLOT void | clear () override |
| | Clears the cache.
|
| |
A custom network cache implementation for RestLink.
This class extends QAbstractNetworkCache to provide custom caching functionality for the RestLink API. It interacts with CachePrivate to manage cache storage and retrieval.
◆ Cache()
| RestLink::Cache::Cache |
( |
QObject * |
parent = nullptr | ) |
|
|
explicit |
◆ ~Cache()
| RestLink::Cache::~Cache |
( |
| ) |
|
Destructor for the Cache class.
This destructor cleans up the cache private data.
◆ maxCacheSize()
| qint64 RestLink::Cache::maxCacheSize |
( |
| ) |
const |
Returns the maximum allowed cache size.
- Returns
- The maximum cache size in bytes.
◆ setMaxCacheSize()
| void RestLink::Cache::setMaxCacheSize |
( |
qint64 |
size | ) |
|
Sets the maximum cache size.
If the new size is different from the current maximum, this function updates the maximum cache size and emits the maxCacheSizeChanged signal.
- Parameters
-
| size | The new maximum cache size in bytes. |
◆ maxCacheSizeChanged()
| Q_SIGNAL void RestLink::Cache::maxCacheSizeChanged |
( |
qint64 |
size | ) |
|
◆ metaData()
| QNetworkCacheMetaData RestLink::Cache::metaData |
( |
const QUrl & |
url | ) |
|
|
override |
Retrieves the metadata for a given URL.
This function fetches the metadata associated with a URL in the cache.
- Parameters
-
| url | The URL whose metadata needs to be retrieved. |
- Returns
- The metadata associated with the URL.
◆ updateMetaData()
| void RestLink::Cache::updateMetaData |
( |
const QNetworkCacheMetaData & |
metaData | ) |
|
|
override |
Updates the cache metadata with the provided data.
- Parameters
-
| metaData | The new metadata to be used in the cache. |
◆ data()
| QIODevice * RestLink::Cache::data |
( |
const QUrl & |
url | ) |
|
|
override |
Retrieves the cached data for a given URL.
This function returns the cached data as a QIODevice object for a given URL.
- Parameters
-
| url | The URL whose cached data needs to be retrieved. |
- Returns
- A QIODevice object with the cached data, or nullptr if no data is found.
◆ remove()
| bool RestLink::Cache::remove |
( |
const QUrl & |
url | ) |
|
|
override |
Removes the cached data for a given URL.
- Parameters
-
| url | The URL whose cached data needs to be removed. |
- Returns
- True if the data was removed successfully, false otherwise.
◆ cacheSize()
| qint64 RestLink::Cache::cacheSize |
( |
| ) |
const |
|
override |
Returns the total size of the cache.
- Returns
- The current size of the cache in bytes.
◆ prepare()
| QIODevice * RestLink::Cache::prepare |
( |
const QNetworkCacheMetaData & |
metaData | ) |
|
|
override |
Prepares a QIODevice to store data in the cache.
This function prepares a QIODevice for writing data associated with a cache metadata entry.
- Parameters
-
| metaData | The metadata of the cache entry to prepare for. |
- Returns
- A QIODevice object for storing the cache data.
◆ insert()
| void RestLink::Cache::insert |
( |
QIODevice * |
device | ) |
|
|
override |
Inserts data into the cache.
This function inserts a QIODevice containing cache data into the cache.
- Parameters
-
| device | The device containing the cache data. |
◆ clear()
| void RestLink::Cache::clear |
( |
| ) |
|
|
override |
Clears the cache.
This function clears all data from the cache.
◆ maxCacheSize
| qint64 RestLink::Cache::maxCacheSize |
|
readwrite |