---
name: "getStorageSync"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "2.0.1" }
  - { name: "@ray-js/ray", version: "0.3.23" }
platform:
  - "iOS"
  - "Android"
title: "getStorageSync - 从本地缓存中异步获取指定 key 的内容的同步版本"
---

## getStorageSync

> [VERSION] BaseKit >= 2.0.1 | @ray-js/ray >= 0.3.23

> [PLATFORM] iOS, Android

### 描述

从本地缓存中异步获取指定 key 的内容

### 参数

| 属性 | 类型 | 必填 | 默认值 | 最低版本 | 描述 |
| --- | --- | --- | --- | --- | --- |
| `key` | `string` | 是 | - | `2.0.1` | 本地缓存中指定的 key |

### 示例代码

#### Demo

```tsx
import { setStorage, getStorage } from '@ray-js/ray'

// 获取本地缓存指定 key 的内容：先写后读，演示完整往返
setStorage({
  key: "demoKey",
  data: "demoValue",
  success: () => {
    getStorage({
      key: "demoKey",
      success: data => console.log("读取内容：", data),
      fail: error => console.error(error),
    });
  },
  fail: error => console.error(error),
});
```
