A Seneca.js plugin
A Seneca plugin that implements the Common Cache API (role:cache) and
the wider memcached command set with a memcached
server. Works with Seneca 3 and Seneca 4 (tested with seneca@4.0.0-rc5)
on Node.js 24 and 22.
![]() |
This open source module is sponsored and supported by Voxgig. |
|---|
npm install seneca @seneca/memcached-cacheYou also need a memcached server, for example
docker run -d -p 11211:11211 memcached:1.6-alpine. In a clone of this
repository, npm run services:up starts one on host port 11311 for the tests.
const Seneca = require('seneca')
const seneca = Seneca()
.quiet()
.use('@seneca/memcached-cache', { servers: ['127.0.0.1:11311'] })
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' }
await seneca.close()
})- Getting started
- Configure the connection
- Use the extended memcached API
- Migrate from Seneca 3
- Runnable programs: docs/examples
Caching is a cross cutting concern that should not tie business logic to
one cache server. With the Common Cache API you send role:cache
messages and choose memcached by loading this plugin. See
How the plugin works.
- GitHub issues
- Seneca documentation
- Sponsored by Voxgig
Full documentation index: docs/README.md.
| Pattern | Reply | Reference |
|---|---|---|
role:cache,cmd:set / add |
{ key } |
Messages |
role:cache,cmd:get |
{ value } |
Messages |
role:cache,cmd:delete |
{ key } |
Messages |
role:cache,cmd:incr / decr |
{ value } |
Messages |
role:cache,cmd:clear |
[true, ...] |
Messages |
role:cache,get:native |
memcached client | Messages |
plugin:memcached-cache,cmd:* |
see reference | Messages |
| Option | Default | Reference |
|---|---|---|
expires |
3600 |
Options |
servers |
['127.0.0.1:11211'] |
Options |
legacy.scalar_results |
false |
Options |
The Senecajs org encourages open participation. To run the tests (Node.js 24 or 22, with the Seneca 4 prerelease devDependency):
npm install
npm run services:up
npm test
npm run services:downSee Run the tests locally. CI
workflow changes are in .patches; apply them with
git am .patches/*.patch.
Implements the Common Cache API for Seneca using memcached; originally written by Seamus D'Arcy and Richard Rodger. See CHANGES.md.
| Plugin version | Seneca | Node.js |
|---|---|---|
| 2.2.x | 3, 4 (4.0.0-rc5 and later) | 24, 22 |
| 2.1.x | 3 | 10 and later |
License: MIT.

