MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / luaSetGlobalArray

Function luaSetGlobalArray

src/scripting.cpp:1343–1352  ·  view source on GitHub ↗

Set an array of Redis String Objects as a Lua array (table) stored into a * global variable. */

Source from the content-addressed store, hash-verified

1341/* Set an array of Redis String Objects as a Lua array (table) stored into a
1342 * global variable. */
1343void luaSetGlobalArray(lua_State *lua, const char *var, robj **elev, int elec) {
1344 int j;
1345
1346 lua_newtable(lua);
1347 for (j = 0; j < elec; j++) {
1348 lua_pushlstring(lua,(char*)ptrFromObj(elev[j]),sdslen((sds)ptrFromObj(elev[j])));
1349 lua_rawseti(lua,-2,j+1);
1350 }
1351 lua_setglobal(lua,var);
1352}
1353
1354/* ---------------------------------------------------------------------------
1355 * Redis provided math.random

Callers 1

evalGenericCommandFunction · 0.85

Calls 4

lua_pushlstringFunction · 0.85
ptrFromObjFunction · 0.85
sdslenFunction · 0.85
lua_rawsetiFunction · 0.85

Tested by

no test coverage detected