GithubHelp home page GithubHelp logo

localstorage_tools's Introduction

localstorge_tools

localstorage工具

支持函数:

dawn_ls_tools.checkCache('键', '传入的时间和localstorage之间的关系(> | >= | == | <= | <)', '要比对的时间(时间戳,不传表示当前时间)' )  // 判断缓存是否过期
dawn_ls_tools.addCache('键', '值', '存入的时间(时间戳,不传表示当前时间)') // 存值
dawn_ls_tools.getCache('键') // 取值
dawn_ls_tools.delCacheByTime('键', '传入时间(时间戳,不传表示当前时间)') // 当前时间或传入时间 大于 缓存时间,删除对应元素

返回值:

假设当前是chrome浏览器
root = window
root.LS_TRUE = 0;
root.LS_NO_PASS_KEY = -1;
root.LS_NO_PASS_CONDITION = -2;
root.LS_NOFIND = -3;
root.LS_NO_MATCH = -4;
root.LS_FALSE = -5;
root.LS_NO_PASS_VALUE = -6;

示例:

var today_0 = new Date(new Date().setHours(0, 0, 0, 0)) / 1000; // 获取今天零点时间
var tomorrow_0 = today_0 + 86400; // 获取明天零点时间
localstorate_tools.addCache('dawnchengx', 'hello wolrd', tomorrow_0); // 添加缓存,并设置存储时间为 明天0点
console.log(localstorate_tools.getCache('dawnchengx')) ; // 打印之前存储的时间
localstorate_tools.delCacheByTime('a'); // 由于当前时间小于 明天零点,所以不会删除

localstorage_tools's People

Contributors

dawnchengx avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.