Skip to content
3 changes: 3 additions & 0 deletions src/scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,9 @@ void scriptingInit(int setup) {

/* Finally set the table as 'redis' global var. */
lua_setglobal(lua,"redis");
/* Set table as 'keydb' global var as well */
lua_getglobal(lua,"redis");
lua_setglobal(lua,"keydb");

/* Replace math.random and math.randomseed with our implementations. */
lua_getglobal(lua,"math");
Expand Down
7 changes: 6 additions & 1 deletion tests/unit/scripting.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,15 @@ start_server {tags {"scripting"}} {
r eval {return redis.call('get',KEYS[1])} 1 mykey
} {myval}

test { EVAL - keys command works? } {
test {EVAL - keys command works? } {
r eval {return redis.call('keys', 'test')} 0
}

test {EVAL - KeyDB global works } {
r eval {return keydb.call('get', KEYS[1])} 1 mykey
assert_equal [r eval {return redis.call('get',KEYS[1])} 1 mykey] [r eval {return keydb.call('get', KEYS[1])} 1 mykey]
}

test {EVALSHA - Can we call a SHA1 if already defined?} {
r evalsha fd758d1589d044dd850a6f05d52f2eefd27f033f 1 mykey
} {myval}
Expand Down