@verdigris/nitrous
v2.2.0
Published
Modern caching framework for node
Downloads
90
Readme
Modern caching library for node.
Usage
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.
External Cache Drivers
Redis
To use Redis driver, you must first install the redis driver:
npm install --save @verdigris/nitrous-driver-redis
Then import the Redis driver and pass it to Cache constructor:
JavaScript
const { Cache } = require("@verdigris/nitrous");
const Redis = require("@verdigris/nitrous-driver-redis");
const redisOptions = {
host: "127.0.0.1",
};
const cache = new Cache(new Redis(redisOptions));
TypeScript
import { Cache } from "@verdigris/nitrous";
import Redis from "@verdigris/nitrous-driver-redis";
const redisOptions = {
host: "127.0.0.1",
};
const cache = new Cache(new Redis(redisOptions));
Memcached
Using the Memcached driver is similar to Redis example. First install the memcached driver:
npm install --save @verdigris/nitrous-driver-memcached
Then import the Memcached driver:
JavaScript
const { Cache } = require("@verdigris/nitrous");
const Memcached = require("@verdigris/nitrous-driver-memcached");
const memcachedOptions = {
poolSize: 10,
};
const cache = new Cache(new Memcached("127.0.0.1", memcachedOptions));
TypeScript
import { Cache } from "@verdigris/nitrous";
import Memcached from "@verdigris/nitrous-driver-memcached";
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.
API Documentation
Detailed API documentation can be found here.
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.