Skip to content

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

5 stars

Watchers

1 watching

Forks

Repository files navigation

Seneca

A Seneca.js plugin

@seneca/redis-cache

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.

npm version build Known Vulnerabilities DeepScan grade

Voxgig This open source module is sponsored and supported by Voxgig.

Install

npm install seneca @seneca/redis-cache

You also need a redis server (default 127.0.0.1:6379).

Quick Example

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()
})

More Examples

The full index is docs/README.md.

Motivation

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.

Support

API

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.

Details: Messages and Errors.

Contributing

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.

Background

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.

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages