For AI agents: the complete documentation index is available at /apps-plugin/docs/llms.txt, the full documentation bundle is available at /apps-plugin/docs/llms-full.txt, and this page is available as Markdown at /apps-plugin/docs/js-api/storage/getStorageInfoSync.md.

getStorageInfoSync

同步获取本地缓存信息。

扫码预览

扫码预览 getStorageInfoSync

支持版本

前端库版本不低于 0.0.19。

支持平台

平台支持情况
Android支持
iOS支持
PC不支持
HarmonyOS不支持

支持场景

场景支持情况
页面支持
卡片支持

使用说明

  • currentSize 与 limitSize 均以 KB 为单位;limitSize 固定为 10240(即 10MB)。

调用方式

同步 API

getStorageInfoSync(params?: object): GetStorageInfoResult

入参

无。

调用示例

import { getStorageInfoSync } from '@doubao-dev/framework/api';

const result = getStorageInfoSync();

console.log(result.keys, result.currentSize, result.limitSize);

返回值

名称类型必返说明
currentSizenumber是当前占用的空间大小,单位 KB
keysstring[]是当前 storage 中所有的 key
limitSizenumber是限制的空间大小,单位 KB

返回示例

{
  "keys": ["profile", "settings"],
  "currentSize": 2,
  "limitSize": 10240
}

错误处理

同步调用失败时抛出错误。错误对象和通用错误码见 通用错误处理。

错误码

通用错误码

errNoerrMsg说明平台
102internal error内部错误Android