Flag parsing #3

Closed
3rd-Eden opened this Issue Jan 30, 2013 · 1 comment

1 participant

@3rd-Eden
Owner

The parser doesn't support parsing of custom flags in VALUE responses from the server. We should expose and API that allows users to specify a custom flag parser.

Specification

The parser exposes an flag api which accepts 2 arguments

  1. a unsigned 16/32bit integer
  2. a parser function

The integer can be 16 or 32 bit, this depends on the memcached version people are running.
Memcached 1.2.0 and lower the flag is a 16-bit integer. In memcached 1.2.1 and higher the flag is a 32-bit integer. So it's up to the developer to select correct flag.

The parser function receives a Buffer instance and returns the parsed value immediately.

// This will parse the response
parser.flag(1, function (buffer) {
  return Number(buffer.toString());
});

TODO

  • Check if we should also supply a string representation of the buffer to the parser.
@3rd-Eden
Owner

912cae6 adds documentation for this change and finalizes this feature.

@3rd-Eden 3rd-Eden closed this Jan 30, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment