logo
On this page

Cache management


Function overview

With the ZIM SDK, you can query the local cache file size of the currently logged-in user and clear the local cache.

Query cache

After creating a ZIM object and logging in, you can invoke the queryLocalFileCache interface and pass ZIMFileCacheQueryConfig to query the size of the cache for the current user locally.

The query result will be returned through the callback interface ZIMFileCacheQueriedCallback.

Untitled
zim::ZIMFileCacheQueryConfig config;
config.endTime = 0; // Query the cache size of the current user before this timestamp (UNIX).
                    // Fill in 0 or a value later than the current time to get the full cache size of the current user.
zim::ZIM::getInstance()->queryLocalFileCache(config, [=](const zim::ZIMFileCacheInfo& fileCacheInfo, const zim::ZIMError& errorInfo) {
    // Query results
});
1
Copied!

Clear cache

After creating a ZIM object and logging in, you can invoke the clearLocalFileCache interface and pass ZIMFileCacheClearConfig to clear the cache for the current user locally.

The clearing result will be returned through the callback interface ZIMFileCacheClearedCallback.

Untitled
zim::ZIMFileCacheClearConfig config;
config.endTime = 0; // Clear the cache of the current user before this timestamp (UNIX).
                    // Fill in 0 or a value later than the current time to clear the complete cache of the current user.
zim::ZIM::getInstance()->clearLocalFileCache(config, [=](const zim::ZIMError& errorInfo) {
    // Get the result of clearing the cache.
});
1
Copied!

Previous

Mark conversations

Next

Overview