# setStorageSync

Call setStorageSync(string key, type data) to set local cache data in the form of key-value pairs.

## Precautions

The maximum data length allowed to be stored in a single key is 1 MB, and the upper limit of all data storage is 10 MB. At the same time, due to limitations of user device storage space, cache cleaning and other mechanisms, information may be lost, so please do not store important data in the local data cache.

## Support

This API only supports gadget calls, and the corresponding client version support is as follows.

App capability | Android | iOS | PC | Harmony | Preview
---|---|---|---|---|---
Gadget | **✓** | **✓** | **✓** | V7.35.0+ | Preview
Web app | **x** | **x** | **x** | **x** | /

## Input

Name | Data type | Required | Default value | Description
---|---|---|---|---
key | string | Yes | \- | Key name. Minimum length is 1 character. Example value: name
data | [local cache data types](https://open.feishu.cn/document/uYjL24iN/uMTOz4yM5MjLzkzM) | No | undefined | The data corresponding to the key name. Example value: DemoName

## Output

None

##  Sample code

```js
try {
    tt.setStorageSync("name", "Xiao Wang");
} catch (error) {
    console.log(`setStorageSync fail: ${JSON.stringify(error)}`);
}
```
