//是否不支持storage
isNoStorage: function(){
if(typeof(Storage)=="function" || window.sessionStorage){
return false;
}else {
return true;
}
},
// 保存
setStorage: function(key, value, isLocal){
var text = JSON.stringify({value: value});
if(isLocal)
window.localStorage.setItem(key, text); //localStorage 方法存储的数据没有时间限制。第二天、第二周或下一年之后,数据依然可用。
else
window.sessionStorage.setItem(key, text); // sessionStorage闭浏览器窗口后,数据会被删除。
},
// 提取
getStorage: function(key, isLocal){
var text;
if (isLocal)
text = window.localStorage.getItem(key);
else
text = window.sessionStorage.getItem(key);
if (!text) return null; var obj = JSON.parse(text);
if (obj)
return obj.value;
},
// 移除
removeStorage: function(key, isLocal){
if (isLocal)
window.localStorage.removeItem(key);
else
window.sessionStorage.removeItem( key );
},
// 清除所有
clearStorage: function(){
window.localStorage.clear();
},
 // 清理过期Storage (value值为日期 )
clearExpireStorage: function(curTime, key, isLocal){
    var Storage = isLocal ? window.localStorage : window.sessionStorage;

    var expireTime = 7*24*3600*1000;
for(var i=0, leng=Storage.length; i<leng; i++){
var skey = Storage.key(i);
var value = Storage.getItem(key); if(key==skey.substring(0,key.length) && ((Number(curTime)-Number(value))>expireTime)){
Storage.removeItem(skey)
}
}
}
 

Storage 的使用的更多相关文章

  1. Azure Queue Storage 基本用法 -- Azure Storage 之 Queue

    Azure Storage 是微软 Azure 云提供的云端存储解决方案,当前支持的存储类型有 Blob.Queue.File 和 Table. 笔者在<Azure File Storage 基 ...

  2. Azure File Storage 基本用法 -- Azure Storage 之 File

    Azure Storage 是微软 Azure 云提供的云端存储解决方案,当前支持的存储类型有 Blob.Queue.File 和 Table. 笔者在<Azure Blob Storage 基 ...

  3. HTML5_06之拖放API、Worker线程、Storage存储

    1.拖放API中源对象与目标对象事件间的数据传递: ①创建全局变量--污染全局对象:  var 全局变量=null;  src.ondragstart=function(){   全局变量=数据值;  ...

  4. HTML5权威指南--Web Storage,本地数据库,本地缓存API,Web Sockets API,Geolocation API(简要学习笔记二)

    1.Web Storage HTML5除了Canvas元素之外,还有一个非常重要的功能那就是客户端本地保存数据的Web Storage功能. 以前都是用cookies保存用户名等简单信息.   但是c ...

  5. MySQL报错:Got error 28 from storage engine

    今天碰到数据库出错: Got error 28 from storage engine 查了一下,数据库文件所在的盘应该没事,应该是数据库用的临时目录空间不够 问题原因: 磁盘临时空间不够导致. 解决 ...

  6. Html 5 Web Storage

    HTML5 中使用Web Storage 技术进行本地存储,能够在Web 客户端进行数据存储.WebStorage 曾今属于HTML5的规范,目前已经被独立出来形成单独的规范体系.简单来说使用Web本 ...

  7. Azure Blob Storage 基本用法 -- Azure Storage 之 Blob

    Azure Storage 是微软 Azure 云提供的云端存储解决方案,当前支持的存储类型有 Blob.Queue.File 和 Table. 笔者在<Azure Table storage ...

  8. Azure Table storage 基本用法 -- Azure Storage 之 Table

    Azure Storage 是微软 Azure 云提供的云端存储解决方案,当前支持的存储类型有 Blob.Queue.File 和 Table,其中的 Table 就是本文的主角 Azure Tabl ...

  9. Windows Azure Storage (6) Windows Azure Storage之Table

    <Windows Azure Platform 系列文章目录> 最近想了想,还是有必要把Windows Azure Table Storage 给说清楚. 1.概念 Windows Azu ...

  10. [New Portal]Windows Azure Storage (14) 使用Azure Blob的PutBlock方法,实现文件的分块、离线上传

    <Windows Azure Platform 系列文章目录> 相关内容 Windows Azure Platform (二十二) Windows Azure Storage Servic ...

随机推荐

  1. 2016级算法期末上机-I.难题·ModricWang's Fight with DDLs III

    1126 ModricWang's Fight with DDLs III 思路 由于题目中已经说明了时间经过了正无穷,因此初始位置是不重要的,并且每条边.每个点的地位是均等的.因此到达每个点的概率就 ...

  2. Oracle数据库学习(四):学习中的遇到的问题

    一.xhost图形化界面安装问题 问题1:运行xhost +命令,出现命令没有找到错误 原因:Linux系统没有安装xhost图形化包. 解决办法:安装xhost图形化包,命令如下: yum what ...

  3. angluarjs的tab标签

    JS代码 $scope.tabs = []; $rootScope.data = { current: "3" // 1代表张三,2代表李四,3代表王五 }; $rootScope ...

  4. 工具篇-大数据组件的一些快捷Shell操作

    一.Hbase 1. HBase shell窗口进入 执行hbase shell 2. HBase表的创建 # 语法:create <table>, {NAME => <fam ...

  5. P1091 合唱队列

    合唱队列 原题:传送门 核心代码: /* 方法求出每一个点的最长升子序列和最长降子序列,再加到该点上 通过循环比较哪个点最大,再用总长减去该点长度即是答案 */ #include<iostrea ...

  6. 洛谷P3980 [NOI2008]志愿者招募

    题解 最小费用最大流 每一天是一条边\((inf-a[i], 0)\) 然后对于一类志愿者, 区间两端连一条\((inf, c[i])\) \(S\)向第一个点连\((inf, 0)\) 最后一个点向 ...

  7. NOIWC 2019 冬眠记【游记】

    在我的blog查看:https://www.wjyyy.top/wc2019 Day -1 上火车了,but手机没电了. Day 0 中午1点左右到了广州东站.接站只有南站和机场有,于是坐了一个多小时 ...

  8. Mac 10.12安装数据库管理工具MySQL Workbench

    说明:跨平台的MySQL管理工具.别纠结是不是反人类的了,这款用熟了也很溜. 下载: (链接: https://pan.baidu.com/s/1b3VtmA 密码: 6hka)

  9. Mac下关闭Sublime Text 3的更新检查

    操作如下: 注意:update_check的属性前后都要有一个逗号. , "update_check":false, 然后还需要一步,就是注册破解,在[Help]->[Ent ...

  10. 新创建的数据库,执行db2look时,遇到package db2lkfun.bnd bind failed

    在新创建的数据库中,执行db2look的时候,存在这样的问题 db2v97i1@oc0644314035 ~]$ db2look -d sample -e -l -o db2look.ddl -- N ...