MCPcopy Create free account
hub / github.com/Tencent/Tendis / luaRedisReturnSingleFieldTable

Function luaRedisReturnSingleFieldTable

src/tendisplus/script/lua_state.cpp:535–546  ·  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

533 * return redis.status_reply("ERR Some Error")
534 */
535int luaRedisReturnSingleFieldTable(lua_State* lua, const char* field) {
536 if (lua_gettop(lua) != 1 || lua_type(lua, -1) != LUA_TSTRING) {
537 luaPushError(lua, "wrong number or type of arguments");
538 return 1;
539 }
540
541 lua_newtable(lua);
542 lua_pushstring(lua, field);
543 lua_pushvalue(lua, -3);
544 lua_settable(lua, -3);
545 return 1;
546}
547
548/* redis.error_reply() */
549int luaRedisErrorReplyCommand(lua_State* lua) {

Callers 2

Calls 1

luaPushErrorFunction · 0.85

Tested by

no test coverage detected