memcache-client is a high-performance Node.js client designed for interacting with Memcached servers, focusing on efficient ASCII protocol parsing through direct Node.js Buffer APIs. Originally developed and heavily used at WalmartLabs for powering the walmart.com e-commerce platform, it offers robust features crucial for large-scale applications. These include optional data compression, automatic reconnection on network errors, support for arbitrary Memcached commands, and the ability to store various data types like Buffer, string, numeric, and JSON. The library provides a flexible API supporting both traditional Node.js callbacks and modern Promise-based operations, alongside features like fire-and-forget requests, multiple connections, and TLS support. It is currently at version 1.0.5 and appears to be in a maintenance or stable release state, with a focus on reliability and performance in demanding environments.
npm install memcache-clientVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates creating a MemcacheClient, setting and retrieving single keys using Promises, concurrently setting multiple keys, and performing a typed multi-key retrieval. It also shows an example of using a callback for deletion.
Install `zstd` on your operating system (e.g., `sudo apt install zstd` on Debian/Ubuntu, `brew install zstd` on macOS) or avoid using the compression option.
Use `client.get<MultiRetrievalResponse<YourValueType>>(['key1', 'key2'])` to ensure correct type inference for the returned object.
When creating the client, pass `{ server: 'localhost:11211', ignoreNotStored: true }` in the options object.Install the `zstd` command-line utility on your operating system (e.g., `sudo apt install zstd` or `brew install zstd`). Ensure it's accessible in the environment where your Node.js application runs.
For single-key `get`, use a generic: `client.get<string>('key')`. For multi-key `get` or `gets`, use the appropriate type helper: `client.get<MultiRetrievalResponse<string>>(['key1', 'key2'])`.If using CommonJS, ensure you're destructuring the named export: `const { MemcacheClient } = require('memcache-client');`. For new projects, it is recommended to use ESM `import { MemcacheClient } from 'memcache-client';` in a `type: "module"` Node.js environment.No dependency data recorded yet.