Skip to content

Feature request: support for meta commands #22

@nfriedly

Description

@nfriedly

Memcached has some new 'meta commands' that extend the text protocol, but do not appear to be supported in memcached-client (and presumably not in the njs server either. I'm not sure if the parser would need changes.)

There is an overview at https://github.com/memcached/memcached/wiki/MetaCommands

They are fully documented here:

I tried using cmd() with a meta command to retrieve the expiration time of a key that I had previously set:

client.cmd('mg mykey t')
  .then(console.log.bind(console, 'success'))
  .catch(console.error.bind(console, 'error'))

but it logs an error and then times out:

No command action defined for [ 'HD', 't31' ]
error Error: Command timeout
[stack trace]

(In the command, mg is for "meta get", t indicates that I want the expiration time. In the response, HD indicates that there is no value, only headers, and t31 indicates that there are 31 seconds left until the expiration.)

I also tried adding the v flag to request a value in addition to the expiration time. It sort-of worked, in that it returned the value rather than timing out. But it still complained rather than returning the expiration time:

No command action defined for [ 'VA', '1', 't60' ]
success 2

I particularly want the Meta Arithmetic command so that I can use it in the rate-limit-memcached rewrite that we're working on to do an "upsert" increment and retrieve the value and TTL all in a single command.

I'd be willing to do some of the work to add these new commands, but I thought it would be smart to start a discussion here to plan out the overall shape of things.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions