抖音开放平台Logo
开发者文档
控制台
  • API 概览
  • C# API
  • 开放接口
  • 转发
  • 群聊
  • 关注
  • 数据分析
  • 基础
  • 渲染
  • 设备
  • 文件
  • 位置
  • 媒体
  • 网络
  • 转发
  • 数据缓存
  • 本地数据缓存
  • tt.clearStorage
  • tt.clearStorageSync
  • tt.getStorage
  • tt.getStorageSync
  • tt.getStorageInfo
  • tt.getStorageInfoSync
  • tt.removeStorage
  • tt.removeStorageSync
  • tt.setStorage
  • tt.setStorageSync
  • 广告
  • 界面
  • 支付
  • Worker
  • tt.getStorageInfoSync
    收藏
    我的收藏

    基础库 1.0.0 开始支持本方法,这是一个同步方法。

    同步获取当前本地缓存数据的相关信息。

    前提条件
    业务背景
    使用限制
    注意事项
    相关教程

    语法

    tt.getStorageInfoSync()

    参数说明

    返回值

    返回值为 object 类型,详细参数描述如下:

    属性名类型说明最低支持版本
    currentSizenumber
    占用空间大小,以 KB 为单位
    1.0.0
    limitSizenumber
    存储空间上限,以 KB 为单位,一般来说会返回 10240
    1.0.0
    keysArray<string>
    string数组,本地数据缓存中的所有键名列表,如无本地数据则返回空数组
    1.0.0

    扫码体验

    请使用字节宿主APP扫码

    代码示例

    开发者工具中预览

    try { var res = tt.getStorageInfoSync(); console.log(res.keys); console.log(res.currentSize); console.log(res.limitSize); } catch (error) { console.log(`getStorageInfoSync调用失败`); }