Sign inDemoInstall


Package Overview
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies



Version published
Install size
61.6 kB



Memcaching Build Status

The central goal of Memcaching is simplicity: to create a Memcache client that is made up of components that do precisely one thing, and combine those components in an easy-to-understand way.

For example, many memcache clients combine network connections, command queueing, protocol details and command semantics more or less all in one module. Here, each task is tackled by a different component:

  • MemcacheClient provides an easy-to-use interface for connecting to a Memcache server (or pool of servers) and issuing commands against it.
    • ConnectionPool serves up connections to a set of servers to be used with consistent hashing, and distributes commands to the correct one based on the hashes of the keys in the command
    • MemcacheSocket represents a connection to a memcached server, and uses a CommandQueue to manage requests to the MemcacheStream on the underlying socket.
      • CommandQueue is responsible for managing a queue of commands to be executed against a resource. Commands are just functions that take two arguments - the resource they want to operate on, and a callback to fire when they are done with it.
      • TextCommandCompiler is used by MemcacheSocket to compile commands from parameters to commands appropriate for use with a CommandQueue serving up a MemcacheStream
        • The commands directory contains implementations for different commands used by Memcache. Each command takes a set of parameters and returns a function that serves as a Command for the CommandQueue, taking a MemcacheStream as the first parameter and a done callback as the second.
      • MemcacheStream is a wrapper than uses DelimitedStream to provide an incredibly simple interface to speak the Memcache text protocol. It handles surfacing errors from the server, reading binary buffers, and parsing responses made of parameter tuples. Uses:
        • DelimitedStream is a wrapper on top of a Node 0.10 Duplex Stream that can send and recv messages delimited by a particular terminator. recv request are guaranteed to be processed in-order. DelimitedStream also uses CommandQueue.

The hope is that by separating out the components it will be easier to understand, test, hack and extend.


Last updated on 17 Jul 2017

Did you know?


Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.


Related posts

SocketSocket SOC 2 Logo


  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap


Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc