nw-wx-storage
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

本地存储

小程序

安装

npm i nw-wx-storage

API

setStorage 设置缓存

  • 类型定义
/**
 * @param   {string}  key     [key]
 * @param   {any}     value   [value]
 * @param   {number}  expire  [expire 过期时间,如: 24 * 60 * 60 = 1天]
 * @return  {void}            [return]
 */
declare const setStorage: (key: string, value: any, expire?: number) => void;
  • 使用,过期时间格式,参考上类型定义中说明
import { setStorage } from 'nw-storage'

setStorage('name', 1) // NAME => 1

getStorage 获取缓存

  • 使用, 如果缓存设置了有效期,失效则返回null
import { getStorage } from 'nw-storage'

getStorage('name') // 1

removeStorage 移除缓存

  • 使用
import { removeStorage } from 'nw-storage'

removeStorage('name') // null

setStorageNameSpace 设置缓存命名空间

  • 使用
import { setStorageNameSpace } from 'nw-storage'

setStorageNameSpace('nw') // NW-NAME => 1

Readme

Keywords

Package Sidebar

Install

npm i nw-wx-storage

Weekly Downloads

2

Version

1.0.7

License

MIT

Unpacked Size

9.64 kB

Total Files

8

Last publish

Collaborators

  • wvlvik