When I run this code through redis EVAL it return no results. Any idea why this is not working?
redis-cli EVAL "$(cat bug.lua)" 0
local retv = {}
retv["test"] = 1000
return retv
If I initialize the table that value alone gets printed.
$ cat bug.lua
--!/usr/bin/env lua
local retv = {"This", "is", "a", "bug" }
retv["test"] = 1000
return retv
$ redis-cli EVAL "$(cat bug.lua)" 2 a b
1) "This"
2) "is"
3) "a"
4) "bug"
Answer from @deltheil is valid.
Remember though that you can use cjson library to pack tables and pass them to consumers.
Your lua file:
local retv = {"This", "is", "a", "bug" }
retv["test"] = 1000
return cjson.encode(retv)
Command:
redis-cli EVAL "$(cat bug.lua)" 0
Result:
"{\"1\":\"This\",\"2\":\"is\",\"3\":\"a\",\"4\":\"bug\",\"test\":1000}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With