Skip to content

makenotion/memcache

Repository files navigation

memcache

NodeJS memcached client with the most efficient ASCII protocol parser.

Notion specifics

Forked from https://github.com/electrode-io/memcache for Notion by Scott Sandler

Our fork is primarily to add support for the meta protocol and a hashring implementation, as well as to enable migration from MemJS.

Private publishing:

The fact that this repo uses lerna makes it harder to install the packages. We need both memcache-client and memcache-parser in our repo. Here's how I did this:

First, update your package.json in each package with their respective new versions. Then,

npm run build
sudo npm i -g gitpkg
cd packages/memcache-parser
gitpkg publish
cd ../memcache-client
gitpkg publish

This uses gitpkg which generates tags in this repo for each of the packages with just the built artifacts.

Then, in notion-next to install you will need to:

  1. Update package.json in the right module with the newest version tag
  2. Update the resolved commit hash in package-lock.json — npm won't re-resolve git dependencies if the lockfile already has a valid commit. Search for memcache-client (or memcache-parser) in package-lock.json and update the commit hash and version number in all occurrences to match the new gitpkg tag.
  3. Remove the cached module and reinstall:
rm -rf src/server-environment/node_modules/memcache-client
npm install

Local development

You can use npm link to test changes to the packages in this repo.

cd packages/memcache-client
npm link

cd <path to your notion-next checkout>
npm link memcache-client

You'll have to explicitly npm run build in the memcache working copy each time you make changes, since npm link symlinks to the dist/ directory containing build artifacts.

Features

  • Very efficient memcached ASCII protocol parser by using only NodeJS Buffer APIs.
  • Optional compression for the data before sending to memcached
  • Auto reconnects when there's network error or timeout
  • Support sending arbitrary commands. Read up on the protocol doc here.
  • Support storing string, numeric, and JSON values
  • APIs Support callback or Promise
  • Support fire and forget requests
  • Support multiple connections
  • Support TLS connections

Packages

This repo uses lerna to manage multiple packages.

Development environment installation

  1. Clone this repo
  2. run nvm use
  3. run npm ci
  4. run npm run bootstrap
  5. optional: just to make sure everything is fine run npm run build and check if there's no error using that command
  6. Testing: run npm test

Publishing notes

  • Recommended publish flow is to publish the modules individually using npm publish, can be improved to use lerna in the future

Other Implementations

License

Apache-2.0 © Joel Chen

About

Node.js memcached client with the most efficient ASCII protocol parser

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors