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. */
| 7192 | * field is not found, or is not a double, return value will be 0, and the |
| 7193 | * optional out_err argument will be set to REDISMODULE_ERR. */ |
| 7194 | double RM_ServerInfoGetFieldDouble(RedisModuleServerInfoData *data, const char* field, int *out_err) { |
| 7195 | double dbl; |
| 7196 | sds val = raxFind(data->rax, (unsigned char *)field, strlen(field)); |
| 7197 | if (val == raxNotFound) { |
| 7198 | if (out_err) *out_err = REDISMODULE_ERR; |
| 7199 | return 0; |
| 7200 | } |
| 7201 | if (!string2d(val,sdslen(val),&dbl)) { |
| 7202 | if (out_err) *out_err = REDISMODULE_ERR; |
| 7203 | return 0; |
| 7204 | } |
| 7205 | if (out_err) *out_err = REDISMODULE_OK; |
| 7206 | return dbl; |
| 7207 | } |
| 7208 | |
| 7209 | /* -------------------------------------------------------------------------- |
| 7210 | * ## Modules utility APIs |