Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: support for meta commands #22

Open
nfriedly opened this issue Aug 25, 2023 · 0 comments
Open

Feature request: support for meta commands #22

nfriedly opened this issue Aug 25, 2023 · 0 comments

Comments

@nfriedly
Copy link
Contributor

nfriedly commented Aug 25, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant