QAbstractNetworkCache 类提供用于实现缓存的接口。 更多...
头: | #include <QAbstractNetworkCache> |
CMake: |
find_package(Qt6 COMPONENTS Network REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Network) |
qmake: | QT += network |
继承: | QObject |
继承者: | QNetworkDiskCache |
virtual | ~QAbstractNetworkCache () |
virtual qint64 | cacheSize () const = 0 |
virtual QIODevice * | data (const QUrl & url ) = 0 |
virtual void | insert (QIODevice * device ) = 0 |
virtual QNetworkCacheMetaData | metaData (const QUrl & url ) = 0 |
virtual QIODevice * | prepare (const QNetworkCacheMetaData & metaData ) = 0 |
virtual bool | remove (const QUrl & url ) = 0 |
virtual void | updateMetaData (const QNetworkCacheMetaData & metaData ) = 0 |
virtual void | clear () = 0 |
QAbstractNetworkCache (QObject * parent = nullptr) |
QAbstractNetworkCache 是每个标准缓存的基类,被用于 QNetworkAccessManager 。QAbstractNetworkCache 是抽象类且不能被实例化。
另请参阅 QNetworkDiskCache .
[protected]
QAbstractNetworkCache::
QAbstractNetworkCache
(
QObject
*
parent
= nullptr)
构造抽象网络缓存采用给定 parent .
[pure virtual slot]
void
QAbstractNetworkCache::
clear
()
Removes all items from the cache. Unless there was failures clearing the cache cacheSize () should return 0 after a call to clear.
在基类中,这是纯虚函数。
另请参阅 cacheSize () 和 remove ().
[虚拟]
QAbstractNetworkCache::
~QAbstractNetworkCache
()
销毁缓存。
Any operations that have not been inserted are discarded.
另请参阅 insert ().
[pure virtual]
qint64
QAbstractNetworkCache::
cacheSize
() const
Returns the current size taken up by the cache. Depending upon the cache implementation this might be disk or memory size.
在基类中,这是纯虚函数。
另请参阅 clear ().
[pure virtual]
QIODevice
*QAbstractNetworkCache::
data
(const
QUrl
&
url
)
返回的数据关联 url .
It is up to the application that requests the data to delete the QIODevice when done with it.
If there is no cache for
url
, the url is invalid, or if there is an internal cache error
nullptr
被返回。
在基类中,这是纯虚函数。
另请参阅 metaData () 和 prepare ().
[pure virtual]
void
QAbstractNetworkCache::
insert
(
QIODevice
*
device
)
Inserts the data in device and the prepared meta data into the cache. After this function is called the data and meta data should be retrievable using data () 和 metaData ().
To cancel a prepared inserted call remove () on the metadata's url.
在基类中,这是纯虚函数。
[pure virtual]
QNetworkCacheMetaData
QAbstractNetworkCache::
metaData
(const
QUrl
&
url
)
返回元数据为 URL url .
If the url is valid and the cache contains the data for url, a valid QNetworkCacheMetaData 被返回。
在基类中,这是纯虚函数。
另请参阅 updateMetaData () 和 data ().
[pure virtual]
QIODevice
*QAbstractNetworkCache::
prepare
(const
QNetworkCacheMetaData
&
metaData
)
Returns the device that should be populated with the data for the cache item
metaData
. When all of the data has been written
insert
() should be called. If
metaData
is invalid or the url in the metadata is invalid
nullptr
被返回。
The cache owns the device and will take care of deleting it when it is inserted or removed.
To cancel a prepared inserted call remove () on the metadata's url.
在基类中,这是纯虚函数。
另请参阅 remove (), updateMetaData (),和 insert ().
[pure virtual]
bool
QAbstractNetworkCache::
remove
(const
QUrl
&
url
)
Removes the cache entry for url , returning true if success otherwise false.
在基类中,这是纯虚函数。
[pure virtual]
void
QAbstractNetworkCache::
updateMetaData
(const
QNetworkCacheMetaData
&
metaData
)
Updates the cache meta date for the metaData 's url to metaData
If the cache does not contains a cache item for the url then no action is taken.
在基类中,这是纯虚函数。