1.0.6 • Published 1 year ago

@awey/dache v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Dache

Use memory,session storagy or local storage to cache things.

Install

# NPM
npm install @awey/dache --save

# Yarn
yarn add @awey/dache

Useage

import Dache from '@awey/dache'

const dache = new Dache('local', 'myDache')
dache.set('username', 'Tom')

console.log(dache.get('username'))

API

  • new Dache(type: 'memory' | 'session' | 'local', name: string) => Dache: init a Dache instance
  • dache.get(key: string) => any: retrieve a value by key from cache
  • dache.set(key: string, value: any) => void: store a value by key to cache
  • dache.remove(key: string) => void: delete a value by key from cache
  • dache.clear() => void: clear all values in cache
  • dache.has(key: string): determines whether a key exists(not null)
  • dache.is(key: string, value: any): determines whether a value is equal(===) to the specified value