目录

Data Storage

Each atomic service can have its own local cache. You can read, write, and clear a local cache through the following APIs.

API

Description

has.setStorage

Stores data in the specified key in the local cache.

has.setStorageSync

Synchronous version of has.setStorage.

has.getStorage

Obtains the cache of the specified key.

has.getStorageSync

Synchronous version of has.getStorage.

has.clearStorage

Clears the local cache.

has.clearStorageSync

Synchronous version of has.clearStorage.

has.removeStorage

Removes the cache of the specified key.

has.removeStorageSync

Synchronous version of has.removeStorageSync.

has.getStorageInfo

Obtains cache information.

has.getStorageInfoSync

Synchronous version of has.getStorageInfo.

Example:

has.setStorageSync('key1', 'test-data');
let res = has.getStorageSync('key1');
console.log(`res = ${res}`);

Isolation Policy

Each user is allocated 10 MB of storage capacity for the same atomic service.

Storage is isolated by user, meaning that on the same device, user A cannot read data of user B. Atomic services are also mutually isolated, preventing cross-service data read and write.

Cleanup Policy

The timing for clearing the local cache is the same as that for clearing an installation package. The local cache is cleared only when the installation package is cleared.