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

Function luaRedisReturnSingleFieldTable

src/scripting.cpp:899–910  ·  view source on GitHub ↗

Returns a table with a single field 'field' set to the string value * passed as argument. This helper function is handy when returning * a Redis Protocol error or status reply from Lua: * * return redis.error_reply("ERR Some Error") * return redis.status_reply("ERR Some Error") */

Source from the content-addressed store, hash-verified

897 * return redis.status_reply("ERR Some Error")
898 */
899int luaRedisReturnSingleFieldTable(lua_State *lua, const char *field) {
900 if (lua_gettop(lua) != 1 || lua_type(lua,-1) != LUA_TSTRING) {
901 luaPushError(lua, "wrong number or type of arguments");
902 return 1;
903 }
904
905 lua_newtable(lua);
906 lua_pushstring(lua, field);
907 lua_pushvalue(lua, -3);
908 lua_settable(lua, -3);
909 return 1;
910}
911
912/* redis.error_reply() */
913int luaRedisErrorReplyCommand(lua_State *lua) {

Callers 2

Calls 6

lua_gettopFunction · 0.85
lua_typeFunction · 0.85
luaPushErrorFunction · 0.85
lua_pushstringFunction · 0.85
lua_pushvalueFunction · 0.85
lua_settableFunction · 0.85

Tested by

no test coverage detected