batchGetStorage(params: Object)

版本要求:
BaseKit≥3.30.1@ray-js/ray≥1.7.60
支持平台:
iOSAndroid
import { batchGetStorage } from '@ray-js/ray';

// Promise 调用
try {
  const res = await batchGetStorage({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

描述

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

参数

属性类型必填说明
keyListstring[]是批量获取的 key 列表
complete() => void否接口调用结束的回调函数(调用成功、失败都会执行)
success(params: Object) => void否接口调用成功的回调函数
fail(params: Object) => void否接口调用失败的回调函数
success 回调参数
属性类型说明
dataListstring[]批量获取的 key-value 列表
fail 回调参数
属性类型说明
errorMsgstring错误信息
errorCodestring | number错误码
错误扩展

返回值

无

示例代码

import { batchSetStorage, batchGetStorage } from '@ray-js/ray'

// 批量获取本地缓存:先批量写入再批量读取,演示完整往返
batchSetStorage({
  kvList: [
    { key: "k1", data: "v1" },
    { key: "k2", data: "v2" },
  ],
  success: () => {
    batchGetStorage({
      keyList: ["k1", "k2"],
      success: data => console.log("批量读取:", data.dataList),
      fail: error => console.error(error),
    });
  },
  fail: error => console.error(error),
});