Skip to content

About

Seneca cache plugin for memcached.

Resources

Code of conduct

Stars

0 stars

Watchers

3 watching

Forks

Repository files navigation

Seneca

A Seneca.js plugin

@seneca/memcached-cache

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.

npm version build Known Vulnerabilities DeepScan grade Maintainability

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

Install

npm install seneca @seneca/memcached-cache

You 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.

Quick Example

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

More Examples

Motivation

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.

Support

API

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

Contributing

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:down

See Run the tests locally. CI workflow changes are in .patches; apply them with git am .patches/*.patch.

Background

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.

About

Seneca cache plugin for memcached.

Resources

Code of conduct

Stars

0 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages