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 queryLocalFileCacheWithConfig 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.
ZIMFileCacheQueryConfig config = new ZIMFileCacheQueryConfig ();
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.queryLocalFileCache(config, new ZIMFileCacheQueriedCallback() {
@Override
public void onFileCacheQueried(ZIMFileCacheInfo fileCacheInfo, ZIMError errorInfo) {
if(errorInfo.code == ZIMErrorCode.SUCCESS) {
// Query results
} else {
// ......
}
}
});
1
ZIMFileCacheQueryConfig *config = [[ZIMFileCacheQueryConfig alloc] init];
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.
[self.zim queryLocalFileCacheWithConfig:config callback:^(ZIMFileCacheInfo *fileCacheInfo, ZIMError *errorInfo) {
if(errorInfo.code == ZIMErrorCodeSuccess) {
// Query results
} else {
// ......
}
}];
1
ZIMFileCacheQueryConfig *config = [[ZIMFileCacheQueryConfig alloc] init];
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.
[self.zim queryLocalFileCacheWithConfig:config callback:^(ZIMFileCacheInfo *fileCacheInfo, ZIMError *errorInfo) {
if(errorInfo.code == ZIMErrorCodeSuccess) {
// Query results
} else {
// ......
}
}];
1
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
try{
ZIMFileCacheQueryConfig config = ZIMFileCacheQueryConfig();
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 complete cache size of the current user.
ZIMFileCacheQueriedResult result = await ZIM.getInstance()!.queryLocalFileCache(config);
// Query cache result
} on PlatformException catch (onError) {
onError.code;
onError.message;
}
1
var config = {
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 clearLocalFileCacheWithConfig interface and pass ZIMFileCacheClearConfig to clear the cache for the current user locally.
The clearing result will be returned through the callback interface ZIMFileCacheClearedCallback.
ZIMFileCacheClearConfig config = new ZIMFileCacheClearConfig ();
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.clearLocalFileCache(config, new ZIMFileCacheClearedCallback() {
@Override
public void onFileCacheCleared(ZIMError errorInfo) {
if(errorInfo.code == ZIMErrorCode.SUCCESS) {
// Get the result of clearing the cache.
} else {
// ......
}
}
});
1
The clearing result will be returned through the callback interface ZIMFileCacheClearedCallback.
ZIMFileCacheClearConfig *config = [[ZIMFileCacheClearConfig alloc] init];
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.
[self.zim clearLocalFileCacheWithConfig:config callback:^(ZIMError *errorInfo) {
if(errorInfo.code == ZIMErrorCodeSuccess) {
// Get the result of clearing the cache.
} else {
// ......
}
}];
1
The clearing result will be returned through the callback interface ZIMFileCacheClearedCallback.
ZIMFileCacheClearConfig *config = [[ZIMFileCacheClearConfig alloc] init];
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.
[self.zim clearLocalFileCacheWithConfig:config callback:^(ZIMError *errorInfo) {
if(errorInfo.code == ZIMErrorCodeSuccess) {
// Get the result of clearing the cache.
} else {
// ......
}
}];
1
The clearing result will be returned through the callback interface ZIMFileCacheClearedCallback.
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
try{
ZIMFileCacheClearConfig config = ZIMFileCacheClearConfig();
config.endTime = 0; // Clear the cache size before this timestamp (UNIX) for the current user.
// Fill in 0 or a value later than the current time to clear the complete cache for the current user.
await ZIM.getInstance()!.clearLocalFileCache(config);
} on PlatformException catch (onError) {
onError.code;
onError.message;
}
1
var config = {
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