0.7.2 • Published 4 years ago

ecache v0.7.2

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

NPM version build status Test coverage David deps node version npm download npm license

node-ecache

Greenkeeper badge DeepScan grade

Easy use Memory and Redis cache implementation

Install

$ npm install ecache --save

How to use

import { InMemoryCache, RedisCache, MRCache } from "ecache";
// const { InMemoryCache, RedisCache, MRCache } = require("ecache");

const inMemoryCache = new InMemoryCache({ ttl: 1 });
const redisCache = new RedisCache({ client: redis, ttl: 1 });
const mrCache = new MRCache({
  redis: { client: redis, ttl: 10 },
  memory: { ttl: 1 },
});

const cache = new InMemoryCache({ ttl: 5 });

// Set Data
await cache.set(KEY, val);
// Get Data
const res = await cache.get(KEY);
// Delete Data
await cache.delete(KEY);

// Use getData and setData
// On concurrency query just run once
cache.setData("getList", (type) => mysql.queryAsync(`SELECT * FROM list where t = "${type}"`));
const list = await cache.getData("getList");
0.7.2

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago