New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

vig-cache

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vig-cache

vig-cache

latest
npmnpm
Version
0.3.1
Version published
Maintainers
1
Created
Source

Build Status Coverage Status

KVCache

Key-value based Cache taking url, params, query and session info into account.

Very simple to use. JSON is recommanded, but String can be saved too.

Improvement

Before:

Requests per second:    12.98 [#/sec] (mean)

After:

Requests per second:    307.32 [#/sec] (mean)

Usage

// for ts
import { KVCache } from "vig-cache";
import * as redis from "redis";

or

// for js
const KVCache = require('vig-cache').KVCache;
const Redis = require("redis");

then

let config = {
  host: '127.0.0.1',
  port: 6379,
  db: 0
};
let redis = Redis.createClient(config);

const cache = new KVCache(redis);

// JSON storage
await cache.setJSON(req, user, {value: 100});
await cache.getJSON(req, user);

// String storage

await cache.set(req, user, 'string');
let saved = await KVCache.get(req, user');
await cache.clear(req);   // For Both JSON and String

// with Expressjs

cache.attach(app)

app.get('/', async function(req, res) {
  if (req.cache.data) {
     return res.send(req.cache.data.text)
  }
 await req.cache.setJSON(req, user, {text: 'toBeCached'});
 res.send('toBeCached');
});

Setting travis and coveralls badges

  • Sign in to travis and activate the build for your project.
  • Sign in to coveralls and activate the build for your project.
  • Replace calidion/vig-cache with your repo details like: "ospatil/generator-node-typescript".

FAQs

Package last updated on 01 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts