2

I am trying to build a redis 'stored procedure' in lua that will update a keyvalue store when one of the map fields changes, and will also extract a value from another key when said value changes. I have built this lua(redis) script and it works.

But I discovered that when I try to enter it into the redis-cli, it complains unless I concatenate all the lines of the script onto one long line. Surely there is a 'continuation character' recognized by the redis-cli (?) but I cannot find it.

Anybody know the continuation character for redis-cli?

ChuckCottrill
  • 4,360
  • 2
  • 24
  • 42
  • I don't think there is one. You can use a client library from python for example. When you are working with Lua, you need something to do the bookkeeping of `SCRIPT LOAD`/`EVAL`/`EVALSHA` for you. If you just want to tryout some stuff from bash, there are many options. Write to file, produce/consume fifo, put in env.var, use echo plus pipe, etcetera etcetera. – Tw Bert Apr 01 '14 at 22:22
  • line breaks are optional in lua. use spaces instead :) – Jasen Apr 12 '15 at 23:39

1 Answers1

2

One option would be to save the lua script to a file and then use the command line to execute the script in the file as shown here:

http://www.redisgreen.net/blog/2013/03/18/intro-to-lua-for-redis-programmers/

I realize this is not a direct answer to what the continuation character for redis-cli might be (or if it exists).

CuriousLayman
  • 207
  • 1
  • 10
  • 1
    The Lua intro for Redis programmers article has been invaluable, but I wanted to have a single sha key and use redis to lookup the functions, which is working except for the difficulty loading these scripts :-( – ChuckCottrill Apr 01 '14 at 21:49
  • I was able to store the lua script in a file, and load it into redis, referring to the loaded script using the SHA key. And I just combined all the lua lines into one long line. – ChuckCottrill Oct 31 '14 at 04:47
  • 1
    line breaks in lua are equivalent to spaces, (except that they also end single-line comments), so if you remove or convert any such comments you can gave a single-line lua script. but seriously – Jasen Apr 12 '15 at 23:38