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. */
| 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. */ |
| 7386 | double 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 |