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

Function moduleCreateCallReplyFromProto

src/module.cpp:3845–3862  ·  view source on GitHub ↗

Create a new RedisModuleCallReply object. The processing of the reply * is lazy, the object is just populated with the raw protocol and later * is processed as needed. Initially we just make sure to set the right * reply type, which is extremely cheap to do. */

Source from the content-addressed store, hash-verified

3843 * is processed as needed. Initially we just make sure to set the right
3844 * reply type, which is extremely cheap to do. */
3845RedisModuleCallReply *moduleCreateCallReplyFromProto(RedisModuleCtx *ctx, sds proto) {
3846 RedisModuleCallReply *reply = (RedisModuleCallReply*)zmalloc(sizeof(*reply), MALLOC_LOCAL);
3847 reply->ctx = ctx;
3848 reply->proto = proto;
3849 reply->protolen = sdslen(proto);
3850 reply->flags = REDISMODULE_REPLYFLAG_TOPARSE; /* Lazy parsing. */
3851 switch(proto[0]) {
3852 case '$':
3853 case '+': reply->type = REDISMODULE_REPLY_STRING; break;
3854 case '-': reply->type = REDISMODULE_REPLY_ERROR; break;
3855 case ':': reply->type = REDISMODULE_REPLY_INTEGER; break;
3856 case '*': reply->type = REDISMODULE_REPLY_ARRAY; break;
3857 default: reply->type = REDISMODULE_REPLY_UNKNOWN; break;
3858 }
3859 if ((proto[0] == '*' || proto[0] == '$') && proto[1] == '-')
3860 reply->type = REDISMODULE_REPLY_NULL;
3861 return reply;
3862}
3863
3864void moduleParseCallReply_Int(RedisModuleCallReply *reply);
3865void moduleParseCallReply_BulkString(RedisModuleCallReply *reply);

Callers 1

RM_CallFunction · 0.85

Calls 2

zmallocFunction · 0.85
sdslenFunction · 0.85

Tested by

no test coverage detected