Last active
April 19, 2017 20:28
-
-
Save itamarhaber/e7dcae6ff5fa18a030ef to your computer and use it in GitHub Desktop.
Snippets accompanying Redis Lua Debugger blog post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rld.start() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rld.start() | |
local function isanswer(n) | |
local answer = 42 | |
if n == answer then | |
return true | |
else | |
return false | |
end | |
end | |
local t = isanswer(ARGV[1]) | |
return ARGV[1] .. " " .. (t and "is" or "isn't") .. " the answer" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo@bar:~$ redis-cli --eval rld.lua | |
"rld v0.1.0 loaded to Redis" | |
foo@bar:~$ redis-cli --eval prog.lua , 42 | |
"42 isn't the answer" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo@bar:~$ tail -n 19 /var/log/redis_6379.log | |
[891] 31 Dec 06:37:09.001 # [rld] -- rld v0.1.0 loaded to Redis | |
[891] 31 Dec 06:37:09.492 # [rld] -- rld v0.1.0 started | |
[891] 31 Dec 06:37:09.492 # [rld] ARGV[1] = '42' | |
[891] 31 Dec 06:37:09.492 # [rld] at Lua:@user_script (line: 10) | |
[891] 31 Dec 06:37:09.493 # [rld] at Lua:@user_script (line: 12) | |
[891] 31 Dec 06:37:09.493 # [rld] new [isanswer] = (function) | |
[891] 31 Dec 06:37:09.493 # [rld] call to function Lua:isanswer | |
[891] 31 Dec 06:37:09.493 # [rld] args [n] = '42' | |
[891] 31 Dec 06:37:09.493 # [rld] at Lua:isanswer (line: 4) | |
[891] 31 Dec 06:37:09.493 # [rld] at Lua:isanswer (line: 5) | |
[891] 31 Dec 06:37:09.493 # [rld] new [answer] = 42 | |
[891] 31 Dec 06:37:09.493 # [rld] at Lua:isanswer (line: 8) | |
[891] 31 Dec 06:37:09.493 # [rld] return from function Lua:isanswer | |
[891] 31 Dec 06:37:09.493 # [rld] at Lua:@user_script (line: 14) | |
[891] 31 Dec 06:37:09.493 # [rld] new [t] is false | |
[891] 31 Dec 06:37:09.493 # [rld] return from function Lua:@user_script | |
[891] 31 Dec 06:37:09.494 # [rld] -- profiler summary: | |
[891] 31 Dec 06:37:09.494 # [rld] -- Lua:isanswer called x1 times | |
[891] 31 Dec 06:37:09.494 # [rld] -- rld exited: end of script. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment