batchSetStorage(params: Object)

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

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

描述

将数据批量存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。

参数

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

返回值

无

示例代码

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

// 批量写入本地缓存(kvList 为 key-value 列表)
batchSetStorage({
  kvList: [
    { key: "k1", data: "v1" },
    { key: "k2", data: "v2" },
  ],
  success: () => console.log("批量写入完成"),
  fail: error => console.error(error),
});