5.1.0 • Published 2 years ago

exp-rediscache v5.1.0

Weekly downloads
5
License
MIT
Repository
github
Last release
2 years ago

rediscache

A Redis caching library meant to be used with exp-asynccache.

Usage:

const cache = new AsyncCache(new RedisCache());

const hit = cache.lookup("foo", (resolve) => {
  resolve(null, "baz");
});

hit.then((value) => {
  console.log(value); // value will be "baz"
});

Values cached with a maxAge uses Redis's SETEX command and sets a TTL on the key.

const cache = new AsyncCache(new RedisCache());

const hit = cache.lookup("foo", (resolve) => {
  resolve(null, "baz", 1000);
});

hit.then((value) => {
  console.log(value); // value will be "baz"
});

The underlying Redis client will queue up any commands if Redis is down. If you want instant errors back you can set the enableOfflineQueue option to false. This allows exp-asynccache to transparently fall back to the resolve callback in such a case.

const cache = new AsyncCache(new RedisCache({
  enableOfflineQueue: false
}));

To namespace your cache keys (in case you run multiple apps against the same Redis), you can specify the keyPrefix option.

const cache = new AsyncCache(new RedisCache({
  keyPrefix: "namespace"
}));

Dev

For local development and running tests:

$ npm ci
$ docker-compose up // starts the local redis instance
$ npm test
5.1.0

2 years ago

5.0.1

3 years ago

5.0.0

3 years ago

4.0.0

4 years ago

3.0.0

4 years ago

2.0.1-beta

4 years ago

2.0.0

7 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago