1.setMemoryCache

功能

将一个键值对保存到缓存中,应用关闭时将失去此记录。

定义

Mobile.setMemoryCache(key, value,err);

Mobile.setMemoryCache(value);

参数

参数名 参数类型 参数描述 参数备注
key String 键名 必填
value String 保存的值 必填
err function 错误信息 可选

参数名 参数类型 参数描述 参数备注
value String DataMap的字符串 必填

范例

Mobile.setMemoryCache("key1", "value1");

var map = new Wade.DataMap();
map.put("key1", "value1");
Mobile.setMemoryCache(map.toString());

备注

2.getMemoryCache

功能

从缓存中读取指定键名的值。

定义

Mobile.getMemoryCache(callback,key,defValue,err);

Mobile.getMemoryCache(callback,key);

参数

参数名 参数类型 参数描述 参数备注
callback function 回调函数 必填
key string 键名 必填
defValue string 默认值 可选
err function 错误信息 可选

参数名 参数类型 参数描述 参数备注
callback function 回调函数 必填
key String数组 键名集合 必填

范例

Mobile.getMemoryCache(function(value){
    console.log("value="+value);
},"key1");

Mobile.getMemoryCache(function(data){
    data = typeof(data) == "string" ? new Wade.DataMap(data) : data;
    data.get("key1");
    data.get("key2");
}, ["key1", "ley2"]);

备注

3.removeMemoryCache

功能

删除缓存中指定键值对。

定义

Mobile.removeMemoryCache(key,err);

Mobile.removeMemoryCache(key,err);

参数

参数名 参数类型 参数描述 参数备注
key string 指定要删除的键名 必填
err function 错误信息 可选

范例

Mobile.removeMemoryCache("key1");

备注

4.clearMemoryCache

功能

清空缓存中所有的键值对。

定义

Mobile.clearMemoryCache(err);

参数

参数名 参数类型 参数描述 参数备注
err function 错误信息 可选

范例

Mobile.clearMemoryCache();

备注

5.setOfflineCache

功能

添加一个键值对到一个相对安全的文件中,退出应用后,数据仍然存在。(存储内容将在加密后保存到本地文件)

定义

Mobile.setOfflineCache(key, value,err);

参数

参数名 参数类型 参数描述 参数备注
key string 键名 必填
value string 保存的值 必填
err function 错误信息 可选

范例

Mobile.setOfflineCache("key1", "value1");

备注

6.getOfflineCache

功能

获取安全文件中指定键名的值。

定义

Mobile.getOfflineCache(callback,key,defValue,err);

参数

参数名 参数类型 参数描述 参数备注
callback function 回调函数 必填
key string 键名 必填
defValue string 默认值 可选
err function 错误信息 可选

范例

Mobile.getOfflineCache(function(value){
    console.log("value="+value);
},"key1");

备注

7.removeOfflineCache

功能

删除安全文件中指定的键值对。

定义

Mobile.removeOfflineCache(key,err);

参数

参数名 参数类型 参数描述 参数备注
key string 指定要删除的键名 必填
err function 错误信息 可选

范例

Mobile.removeOfflineCache("key1");

备注

8.clearOfflineCache

功能

清空安全文件中所有的键值对。

定义

Mobile.clearOfflineCache(err);

参数

参数名 参数类型 参数描述 参数备注
err function 错误信息 可选

范例

Mobile.clearOfflineCache();

备注

Copyright © aiipu.com 2017 all right reserved,powered by Gitbook该文件修订时间: 2020-09-01 15:11:34

results matching ""

    No results matching ""