Memcache Plus

raw JSON →
0.3.1 verified Fri May 01 auth: no javascript

memcache-plus is a Node.js memcache client with native Promise support, Elasticache auto-discovery, command buffering, and built-in compression. Current stable version is 0.3.1. Released irregularly. It differentiates from other memcache clients (like memcached) by providing a clean Promise-based API, automatic Elasticache cluster detection, and a flag to disable caching for testing. Supports both callbacks and Promises, and allows starting commands before connection (buffering).

error Error: connect ECONNREFUSED 127.0.0.1:11211
cause Memcached server is not running or port is wrong.
fix
Start memcached: memcached -d start or check the host/port.
error TypeError: client.get is not a function
cause Using the client before calling connect() or mixing import styles.
fix
Await client.connect() first, or use the ESM import: import MemcachePlus from 'memcache-plus'.
error Cannot find module 'memcache-plus'
cause Package not installed or incorrectly installed.
fix
Run: npm install memcache-plus
breaking The connect() method must be awaited; otherwise commands may fail silently.
fix Always await client.connect() before issuing commands.
deprecated Callback-based API is deprecated in favor of Promises.
fix Use async/await or .then() instead of callbacks.
gotcha The set() method expects a TTL in seconds (not milliseconds) – common mistake.
fix Pass TTL in seconds, e.g., 3600 for 1 hour.
gotcha Elasticache auto-discovery expects a configuration endpoint, not a node list.
fix For Elasticache, pass the configuration endpoint URL as the host string.
npm install memcache-plus
yarn add memcache-plus
pnpm add memcache-plus

Shows how to create a client, connect, set/get/delete values, and disconnect.

const MemcachePlus = require('memcache-plus');

async function main() {
  const client = new MemcachePlus(['127.0.0.1:11211']);

  // Wait for connection
  await client.connect();

  // Set a value
  await client.set('key', 'value', 3600);

  // Get a value
  const val = await client.get('key');
  console.log(val); // 'value'

  // Delete
  await client.delete('key');

  // Disconnect
  client.disconnect();
}

main().catch(console.error);