How to use the memjs.Server function in memjs

To help you get started, we’ve selected a few memjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github memcachier / memjs / bench / memjs.js View on Github external
var responseHeader = {
    magic: 0x81,
    opcode: 1,
    keyLength: 15,
    extrasLength: 0,
    dataType: 0,
    status: 1,
    totalBodyLength: 1024 * 10 + 15,
    opaque: 0,
    cas: Buffer.from([0x0a, 0, 0, 0, 0, 0, 0, 0])
  };
  var buf = Buffer.alloc(24 + 15 + 1024 * 10);
  header.toBuffer(responseHeader).copy(buf);
  buf.write(makeString(55));

  var server = new memjs.Server();

  var dummyFunc = function(arg) {
    server.onResponse(dummyFunc);
    return arg;
  };

  var i;
  for (i = 0; i < 10; i++) {
    server.onResponse(dummyFunc);
  }

  suite.add('Server#respond', function() {
    server.respond('helloworldthisisatesttohowmuchyouareaversetocopyingoverthestargatecommisionandromanticizingaboutmylifelongpassionforlearningandyieldingtoyourdesires');
  })
  .add('Server#responseHandler', function() {
    server.responseHandler(buf);

memjs

A memcache client for node using the binary protocol and SASL authentication

MIT
Latest version published 4 months ago

Package Health Score

71 / 100
Full package analysis