7

Redis supports lua scripting. Using eval command, we can execute a lua script in redis. Is the lua script compiled or interpretted when redis calls a lua script?

Ridhima
  • 308
  • 1
  • 3
  • 14
  • 4
    What do you believe the difference between those two would be in this case? What question are you really trying to ask? – Etan Reisner Apr 01 '15 at 13:11

1 Answers1

7

Lua scripts sent to the Lua library for execution are always compiled to Lua VM instructions before execution. These instructions are then interpreted by the Lua VM.

lhf
  • 70,581
  • 9
  • 108
  • 149
  • Here http://intro2libsys.info/introduction-to-redis/lua-scripting it is written that redis has a lua interpreter. Does it mean that when redis makes a call to execute a lua script, it is interpretted and not compiled? – Ridhima Apr 02 '15 at 07:00
  • 2
    Redis wraps your script into a function and uses [`luaL_loadbuffer`](http://www.lua.org/manual/5.1/manual.html#luaL_loadbuffer) as you can see [here](https://github.com/antirez/redis/blob/902b877/src/scripting.c#L850-L865). – deltheil Apr 02 '15 at 08:12
  • 1
    Good to know actually! And the compilation should be done only once as you send only SHA1 for next lua calls. – zenbeni Apr 02 '15 at 15:51