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 ZIMFileCacheQueriedResult.
Untitled
const config: ZIMFileCacheQueryConfig = {
endTime: 0 // Query the cache size for the current user before this timestamp (UNIX). Fill in 0 or a value later than the current time to get the complete cache size for the current user.
};
zim.queryLocalFileCache(config)
.then(function ({ totalFileSize }) {
// Operation succeeded
})
.catch(function (err) {
// Operation failed
});
1
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.
Untitled
const config: ZIMFileCacheClearConfig = {
endTime: 0 // Clear the cache size for the current user before this timestamp (UNIX). Fill in 0 or a value later than the current time to clear the complete cache size for the current user.
};
zim.clearLocalFileCache(config)
.then(function () {
// Operation succeeded
})
.catch(function (err) {
// Operation failed
});
1