Each atomic service can have its own local cache. You can read, write, and clear a local cache through the following APIs.
API | Description |
|---|---|
Stores data in the specified key in the local cache. | |
Synchronous version of has.setStorage. | |
Obtains the cache of the specified key. | |
Synchronous version of has.getStorage. | |
Clears the local cache. | |
Synchronous version of has.clearStorage. | |
Removes the cache of the specified key. | |
Synchronous version of has.removeStorageSync. | |
Obtains cache information. | |
Synchronous version of has.getStorageInfo. |
Example:
has.setStorageSync('key1', 'test-data');
let res = has.getStorageSync('key1');
console.log(`res = ${res}`);