Modern caching library for node.
To get started, run:
npm install --save @verdigris/nitrous
Then in your code, import the package:
const { Cache } = require("@verdigris/nitrous");
const cache = new Cache();
By default, nitrous will use in-memory driver that uses node-cache as an underlying cache store and does not ship with third-party caching client libraries such as redis or memcached modules to reduce the distribution size of the library.
To use Redis driver, you must first install the redis module:
npm install --save redis
Then import the Redis driver and pass it to Cache constructor:
const {
Cache,
drivers: { Redis }
} = require("@verdigris/nitrous");
const redisOptions = {
host: "127.0.0.1"
};
const cache = new Cache(new Redis(redisOptions));
Using the Memcached driver is similar to Redis example. First install the memcached module:
npm install --save memcached
Then import the Memcached driver:
const {
Cache,
drivers: { Memcached }
} = require("@verdigris/nitrous");
const memcachedOptions = {
poolSize: 10
};
const cache = new Cache(new Memcached("127.0.0.1", memcachedOptions));
NOTE: Anything other than Memcached version 1.5.0 seems to cause intermittent issues that relies on calls to
stats cachedump
. If this is an issue, please report this issue to the upstream library for memcached.
Detailed API documentation can be found here.
This library was written entirely in TypeScript and you will be able to import this library without
having to install typings (e.g. @types/<package>
).
Example:
import { Cache, drivers } from "@verdigris/nitrous";
const driver = new drivers.Redis({ host: "127.0.0.1" });
const cache = new Cache(driver);
Copyright © 2020 Verdigris Technologies, Inc. All rights reserved.
Verdigris Technologies Inc. assumes NO RESPONSIBILITY OR LIABILITY UNDER ANY CIRCUMSTANCES for usage of this software. See the LICENSE.md file for detailed legal information.
Generated using TypeDoc