Skip to content

Add example vanilla JS script showing how to define and execute a Lua script that takes parameters #1689

@simonprickett

Description

@simonprickett

Add an example script that shows how to set up a Lua script in Redis and execute it. Your script should take two Redis keys as arguments and one other numeric argument. Have the script increment the value stored at each of the keys by the value passed as a numeric argument.

e.g. if key mykey doesn't exist, and key myotherkey holds the value 5, then running the script passing keys mykey and myotherkey and the value 10 should result in mykey holding 10 and myotherkey holding 15.

See the Lua Scripts section of the node-redis README for guidance on how to declare and execute scripts.

Name your file lua-multi-incr.js. Name the JS function containing your code luaMultiIncr and name the Lua script mincr in node-redis' scripts when creating your client instance.

Pay attention to the guidelines for adding an example here when doing this.

This is part of our participation in Hacktoberfest 2021. Learn how to complete this issue here: https://developer.redis.com/hacktoberfest/

Need help or want to talk to us? Join us on Discord where we have a dedicated Hacktoberfest channel: https://discord.gg/ueQwKUh5Z3

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions