liuqwert / js-api-cache

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

js-api-cache

improve experience by caching api returns

Installation:

npm i js-api-cache

Usage:

import { cache, clearCache, setDebug } from 'js-api-cache'

setDebug(true)

//CRUD api cache samples for Xxxx object

@cache({ maxAge: 300000, cacheName: 'Xxxx' })
async listXxxx() {
	... 	// fectch url
    return xArray
}

@cache({ maxAge: 300000, cacheName: 'Xxxx' })
async getXxxx() {
	...
    return xObject
}

@cache({ maxAge: 300000, cacheName: 'Xxxx' })
async addXxxx() {
	...
    return xObjectOrId
}  

@cache({ maxAge: 300000, cacheName: 'Xxxx' })
async updateXxxx() {
	...
    return xObjectOrId
}  

@cache({ maxAge: 300000, cacheName: 'Xxxx' })
async deteleXxxx() {
	...
} 

About

License:MIT License


Languages

Language:JavaScript 100.0%