Add KeyDB global variable to lua api (#606)

This commit is contained in:
Malavan Sotheeswaran 2023-03-14 13:45:29 -07:00 committed by GitHub
parent deaaa992bd
commit 06380e5fe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -1264,6 +1264,9 @@ void scriptingInit(int setup) {
/* Finally set the table as 'redis' global var. */ /* Finally set the table as 'redis' global var. */
lua_setglobal(lua,"redis"); 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. */ /* Replace math.random and math.randomseed with our implementations. */
lua_getglobal(lua,"math"); lua_getglobal(lua,"math");

View File

@ -47,6 +47,11 @@ start_server {tags {"scripting"}} {
r eval {return redis.call('keys', 'test')} 0 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?} { test {EVALSHA - Can we call a SHA1 if already defined?} {
r evalsha fd758d1589d044dd850a6f05d52f2eefd27f033f 1 mykey r evalsha fd758d1589d044dd850a6f05d52f2eefd27f033f 1 mykey
} {myval} } {myval}