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

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

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.

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

Previous

Set conversation draft

Next

Overview