# expeditious-engine-redis

> redis engine for expeditious caches

Latest version **0.1.2** (published 2019-01-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install expeditious-engine-redis
pnpm add expeditious-engine-redis
yarn add expeditious-engine-redis
bun add expeditious-engine-redis
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2019-01-24 |
| First published | 2017-02-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.4 |
| Dependencies | 4 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| Author | Evan Shortiss |
| Maintainers | evanshortiss |
| Keywords | expeditious, engine, cache, redis, express-expeditious, express |

## Links

- npm: https://www.npmjs.com/package/expeditious-engine-redis
- Repository: https://github.com/evanshortiss/expeditious-engine-redis
- Homepage: https://github.com/evanshortiss/expeditious-engine-redis#readme
- Issues: https://github.com/evanshortiss/expeditious-engine-redis/issues
- npm.io page: https://npm.io/package/expeditious-engine-redis

## Dependencies (4)

- [async](https://npm.io/package/async.md) ~2.0.0
- [redis](https://npm.io/package/redis.md) ~2.6.2
- [verror](https://npm.io/package/verror.md) ~1.9.0
- [expeditious](https://npm.io/package/expeditious.md) ~0.1.0

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 0.1.2 (latest) — 2019-01-24
- 0.1.1 — 2017-02-08
- 0.1.0 — 2017-02-03

## README

expeditious-engine-redis
========================

![TravisCI](https://travis-ci.org/evanshortiss/expeditious-engine-redis.svg)

An in redis engine for expeditious. Cache entries are - you guessed it -
stored in a redis instance.

## Usage
You can use this module standalone or with expeditious which is the
recommended approach since it simplifies interactions and allows you to easily
switch cache engines.

```js
const expeditious = require('expeditious');

// This will be passed to redis.createClient(options)
// https://www.npmjs.com/package/redis#rediscreateclient
const redisOptions = {
  host: 'redis-server.acme.com',
  port: 6379
};

const countries = expeditious({
  // Use the expeditious memory engine
  engine: require('expeditious-engine-redis')({redis: redisOptions}),
  // Prefix all entries with 'countries'
  namespace: 'countries',
  // Auto parse json entries
  objectMode: true,
  // 1 hour timeout for entries
  defaultTtl: (60 * 1000 * 60),
});

countries.set({
  key: 'ireland',
  value: {
    population: '4.595 million',
    capital: 'Dublin'
  }
}, function (err) {
  if (!err) {
    console.error('failed to add "ireland" to the cache');
  } else {
    console.log('add "ireland" to the cache');
  }
});
```

## API
Each API function takes a callback function as the last parameter and it
receives up to two arguments as per node.js convention, error _err_ and an
optional result, _res_.

#### set(key, value, expire, callback)
Set a _key_ (String) in the cache with a given (String) _value_. _expire_ must
be a Number greater than 0.

#### get(key, callback)
Get a specific item from the cache. Returns _null_ if the entry is
not found.

#### del(key, callback)
Delete a specific item from the cache. Callback receives only an error
parameter.

#### keys(ns, callback)
List all keys that this engine instance contains for the given namespace. This
can be expensive as per the reddit docs for KEYS.

#### ttl(key, callback)
Get the time left before _key_ expires. Returns _null_ as _res_ if the entry is
not found.

#### flush(ns, callback)
Flush all items from the engine instance in the given namespace.

---
_Source: https://npm.io/package/expeditious-engine-redis · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
