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

Adding new builtin commands and transformers #621

Closed
ksmithut opened this issue Apr 17, 2018 · 4 comments
Closed

Adding new builtin commands and transformers #621

ksmithut opened this issue Apr 17, 2018 · 4 comments

Comments

@ksmithut
Copy link
Contributor

I am currently playing around with redis streams (and here which add some new commands. I don't think these commands are available for production use, but I assume they'll be added to the list of commands currently in the redis-commands module when they're ready.

Until then, I'm currently looking to add these commands to my ioredis instance. What is the best way to do this that will support things like pipelines and transactions? The way I got it to work seems hacky (using and overriding prototypes), but this is what I've got so far:

const { string, buffer } = Redis.prototype.createBuiltinCommand('xadd')
Redis.prototype.xadd = string
Redis.prototype.xaddBuffer = buffer
Redis.Command.setArgumentTransformer('xadd', args => /* TODO */ args)
Redis.Command.setReplyTransformer('xadd', reply => /* TODO */ reply)
@ksmithut
Copy link
Contributor Author

It appears that this doesn't add it to the multi pipelining. It would be great to have an answer for this, even if the answer is "we don't support adding custom commands".

@ksmithut
Copy link
Contributor Author

ksmithut commented May 10, 2018

I got it working with pipeline by adding the "string" and "buffer" from above to the Pipeline prototype by directly requiring ioredis/lib/pipeline. Gross... I'm just going to wait until you guys support the new stream commands

@luin
Copy link
Collaborator

luin commented May 11, 2018

Sorry for the late response! Yes, adding commands to pipeline directly should do the trick. XADD command will be added as soon as it's added to the redis-commands package.

@ksmithut
Copy link
Contributor Author

Awesome, thanks :)

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

2 participants