0.1.5 • Published 5 years ago

gocache v0.1.5

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

gocache

Get-Or-CACHEd Caching structure, that returns a result of provided callback invocation with caching it for specified time. Expiration is not precise and may vary due to callback call duration.

Usage

let myCachedObject = new GOCache(5000, () => {
    return Date.now();
})
setInterval(() => console.log(myCachedObject.get()), 1000) 
// expected to print same number 5 times

with express.js, request-promise-native

let router = require('express').Router();
const GOCache = require("gocache");
const request = require('request-promise-native');
const TIME = 10000;

let CachedPage = new GOCache(TIME, async () => await request("https://google.com"))
Router.get('/cached-page', async (req, res) => res.send(CachedPage.get()));

FAQ

  1. .get() returns undefined or something else unwanted.

    Make sure your callback exactly returns data you want, not pending promise or something.

0.1.5

5 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago