req-caching
TypeScript icon, indicating that this package has built-in type declarations

1.1.7 • Public • Published

Req Caching

Easily cache all types of request

note: This package is under Development;

Getting Started

npm i req-caching

Now in index.js, initialize class

import Caching from "req-caching"

const Store = new Caching("localstorage")

Adding a element to store

Before you add element, lets look at some keywords

  1. Key - A string considering as a name to cache element. Can be treated as key to Associative Array.
  2. Seed - A function which must return some value, which will be treated as value of element. This function will be called whenever element value is needed.
  3. MaxAge - Maximum age for caching. Once the time expires, Seed Function will be called and a new cache value is stored with new Age.

Now you will have to register a new element

const seed = async () => {
    // any steps
    // just fetch value as you need
    // and return them
    return value
}
// add method registers an element and it can be used afterwards
await Store.add('unique-key', seed [, Extra Opts])

Extra Options

interface OPTS{
    maxAge?:{
        seconds ?: number [default: 60]
        minutes ?: number [default: 0]
        hours ?: number [default: 0]
    },
    strict ?: boolean [default: false],
    encrypt ?: boolean [default: false],

}

Getting values

Congratulations, now as when you have registered all your elements, you now just need to call Store. Store will manage all things.

let my_var = await Store.get("my_var")
Thank You
Made with Love by Hrishikesh

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.1.71latest

Version History

VersionDownloads (Last 7 Days)Published
1.1.71
1.1.60
1.1.50
1.1.40
1.1.30
1.1.20
1.1.10
1.1.00
1.0.150
1.0.140
1.0.130
1.0.120
1.0.111
1.0.100
1.0.90
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.11
1.0.00

Package Sidebar

Install

npm i req-caching

Weekly Downloads

1

Version

1.1.7

License

ISC

Unpacked Size

37.9 kB

Total Files

20

Last publish

Collaborators

  • hrishikesh.214