A Seneca.js plugin
A Seneca plugin that implements the Seneca cache API (role:cache) on a redis server, using the redis v3 Node.js client. Works with Seneca 3 and the Seneca 4 prerelease (4.0.0-rc5) on Node 22 and 24.
![]() |
This open source module is sponsored and supported by Voxgig. |
|---|
npm install seneca @seneca/redis-cache
You also need a redis server (default 127.0.0.1:6379).
const Seneca = require('seneca')
const seneca = Seneca().use('@seneca/redis-cache', {
redis: { host: '127.0.0.1', port: 6379 },
})
seneca.ready(async function () {
await seneca.post('role:cache,cmd:set', { key: 'k1', val: 'v1' })
const out = await seneca.post('role:cache,cmd:get', { key: 'k1' })
console.log(out) // { value: 'v1' }
seneca.close()
})- Getting started, with the runnable example program.
- Configure the redis connection
- Use the native redis client
- Run the tests locally
The full index is docs/README.md.
Seneca defines a common cache API so that services can swap cache back ends without code changes. This plugin provides that API on redis. See How the plugin works.
- Post a GitHub issue.
- Read the Seneca documentation.
- This module is sponsored and supported by Voxgig.
| Option | Default | Reference |
|---|---|---|
expire |
3600 seconds |
Options |
redis |
{ port: 6379, host: '127.0.0.1' } |
Options |
| Pattern | Purpose |
|---|---|
role:cache,cmd:set |
Store a value. |
role:cache,cmd:get |
Read a value. |
role:cache,cmd:add |
Store a value if the key is new. |
role:cache,cmd:delete |
Delete a key. |
role:cache,cmd:incr |
Increment a number. |
role:cache,cmd:decr |
Decrement a number. |
role:cache,cmd:clear |
Flush the redis server. |
role:cache,get:native |
Get the redis client. |
The Senecajs org encourages open participation.
To run the tests (Node 24 or 22, with the seneca@4.0.0-rc5 devDependency):
npm install
npm run services:up
npm test
npm run services:down
See Run the tests locally for the
environment variables. CI workflow changes are in .patches/; apply them with
git am .patches/*.patch.
Originally written by Seamus D'Arcy and Richard Rodger. See CHANGES.md for history.
| Plugin | Seneca | Node | redis client |
|---|---|---|---|
| 2.1.x | 3.x, 4.0.0-rc5 and later | 22, 24 | redis 3 |
| 2.0.x | 3.x | older | redis 3 |
Licensed under MIT.

