数据缓存
清理本地数据缓存
await ymx.clearStorage(); 复制
await ymx.clearStorage();
从本地缓存中异步获取指定 key 的内容
const res = await ymx.getStorage({ key: 'key1'});console.log(res); 复制
const res = await ymx.getStorage({ key: 'key1'});console.log(res);
异步获取当前 storage 的相关信息
ymx.getStorageInfo().then(res => { alert(JSON.stringify(res));}); 复制
ymx.getStorageInfo().then(res => { alert(JSON.stringify(res));});
从本地缓存中移除指定 key
await ymx.removeStorage({ key: 'key1'}); 复制
await ymx.removeStorage({ key: 'key1'});
将数据存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。
await ymx.setStorage({ key: 'key1', data: 'value 1'}); 复制
await ymx.setStorage({ key: 'key1', data: 'value 1'});
await ymx.setStorage({ key: 'key2', data: { name: '张三', age: 26 }}); 复制
await ymx.setStorage({ key: 'key2', data: { name: '张三', age: 26 }});
数据缓存