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.removeStorage. |
| has.getStorageInfo | Obtains cache information. |
| has.getStorageInfoSync | Synchronous version of has.getStorageInfo. |
Example:
has.setStorageSync('key1', 'test-data');
let res = has.getStorageSync('key1');
console.info(`res = ${res}`);