logo
In-app Chat
SDK Error Codes
Powered Byspreading
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 ZIMFileCacheQueriedResult.

Untitled
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
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.

Untitled
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
Copied!

Previous

Mark conversations

Next

Overview