Git Product home page Git Product logo

wcache's Introduction

wCache

微信小程序缓存框架,支持数组、json、字符串……支持设置缓存时间、支持缓存读取失败默认值。

一、公共方法

put(k, v, t)

k为key,v为具体内容(支持字符串、json、数组、boolean等等),t为可选参数表示过期时间(单位:秒)
如存储k为123过期时间1秒,则调用put('k', '123', 1)方法;若永久存储调用put('k', '123')
永久保存json:put('k', {"a":"1"}),数组、boolean等同理。

get(k, def)

k为key,def为可选参数,表示无缓存数据时返回值(支持字符串、json、数组、boolean等等)
如读取k缓存,则调用get('k');若想要无缓存时,返回默认值则get('k','默认值'),支持各个数据类型。

remove(k)

移除某个key

clear()

清空所有key

other

使用wx原生的即可。
如何使用

二、如何使用

  1. 下载src文件夹内wCache.js文件
  2. 需要使用的js文件头加入var wc = require('../../src/wcache.js')。
  3. var s=wc.get('k', '你好')、wc.put('k', 'string你好啊')等;

源码解释见:https://juejin.im/post/591af94b2f301e006bc61687

wcache's People

Contributors

qq273681448 avatar

Watchers

James Cloos avatar  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.