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

Function RM_ServerInfoGetFieldDouble

src/module.cpp:7386–7399  ·  view source on GitHub ↗

Get the value of a field from data collected with RM_GetServerInfo(). If the * field is not found, or is not a double, return value will be 0, and the * optional out_err argument will be set to REDISMODULE_ERR. */

Source from the content-addressed store, hash-verified

7384 * field is not found, or is not a double, return value will be 0, and the
7385 * optional out_err argument will be set to REDISMODULE_ERR. */
7386double RM_ServerInfoGetFieldDouble(RedisModuleServerInfoData *data, const char* field, int *out_err) {
7387 double dbl;
7388 sds val = (sds)raxFind(data->rax, (unsigned char *)field, strlen(field));
7389 if (val == raxNotFound) {
7390 if (out_err) *out_err = REDISMODULE_ERR;
7391 return 0;
7392 }
7393 if (!string2d(val,sdslen(val),&dbl)) {
7394 if (out_err) *out_err = REDISMODULE_ERR;
7395 return 0;
7396 }
7397 if (out_err) *out_err = REDISMODULE_OK;
7398 return dbl;
7399}
7400
7401/* --------------------------------------------------------------------------
7402 * ## Modules utility APIs

Callers

nothing calls this directly

Calls 3

raxFindFunction · 0.85
string2dFunction · 0.85
sdslenFunction · 0.85

Tested by

no test coverage detected