1.0.13 • Published 4 years ago

@junaid1460/simple-redis-cache v1.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Simple redis cache

Cache data easily with a simple wrap.

npm i @junaid1460/simple-redis-cache

Usage

typescript:
import { RedisCache } from "@junaid1460/simple-redis-cache";

const cache = new RedisCache({
    host: "localhost",
});

function myFunc(x: number, y: number) {
    return cache.cached({
        expiresAfter: 10, // seconds
        keys: [x, y], // list of number or string to construct key
        // closure
        func: async () => {
            return x * y;
        },
    });
}

myFunc(1, 2).get().then((e) => console.log(e.hit, e.data));
Javascript:
const redisCache = require('@junaid1460/simple-redis-cache')
const cache = new redisCache.RedisCache({
    host: 'localhost'
})


function myFunc(x, y) {
    return cache.cached({
        expiresAfter: 10, // seconds
        keys: [x, y], // list of number or string to construct key
        // closure
        func: async () => {
            return x * y;
        },
    });
}

myFunc(1, 2).delete().then((e) => console.log());
1.0.13

4 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago