mirror of
https://github.com/fluencelabs/redis
synced 2025-06-21 21:11:33 +00:00
Adding RM_ServerInfoGetFieldC
This commit is contained in:
14
src/module.c
14
src/module.c
@ -5534,11 +5534,17 @@ RedisModuleString *RM_ServerInfoGetField(RedisModuleCtx *ctx, RedisModuleServerI
|
||||
return o;
|
||||
}
|
||||
|
||||
/* Similar to RM_ServerInfoGetField, but returns a char* which should not be freed but the caller. */
|
||||
const char *RM_ServerInfoGetFieldC(RedisModuleServerInfoData *data, const char* field) {
|
||||
sds val = raxFind(data->rax, (unsigned char *)field, strlen(field));
|
||||
if (val == raxNotFound) return NULL;
|
||||
return val;
|
||||
}
|
||||
|
||||
/* Get the value of a field from data collected with RM_GetServerInfo(). If the
|
||||
* field is not found, or is not numerical, return value will be 0, and the
|
||||
* optional out_err argument will be set to REDISMODULE_ERR. */
|
||||
long long RM_ServerInfoGetFieldNumerical(RedisModuleCtx *ctx, RedisModuleServerInfoData *data, const char* field, int *out_err) {
|
||||
UNUSED(ctx);
|
||||
long long RM_ServerInfoGetFieldNumerical(RedisModuleServerInfoData *data, const char* field, int *out_err) {
|
||||
long long ll;
|
||||
sds val = raxFind(data->rax, (unsigned char *)field, strlen(field));
|
||||
if (val == raxNotFound) {
|
||||
@ -5556,8 +5562,7 @@ long long RM_ServerInfoGetFieldNumerical(RedisModuleCtx *ctx, RedisModuleServerI
|
||||
/* 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. */
|
||||
double RM_ServerInfoGetFieldDouble(RedisModuleCtx *ctx, RedisModuleServerInfoData *data, const char* field, int *out_err) {
|
||||
UNUSED(ctx);
|
||||
double RM_ServerInfoGetFieldDouble(RedisModuleServerInfoData *data, const char* field, int *out_err) {
|
||||
double dbl;
|
||||
sds val = raxFind(data->rax, (unsigned char *)field, strlen(field));
|
||||
if (val == raxNotFound) {
|
||||
@ -6862,6 +6867,7 @@ void moduleRegisterCoreAPI(void) {
|
||||
REGISTER_API(GetServerInfo);
|
||||
REGISTER_API(FreeServerInfo);
|
||||
REGISTER_API(ServerInfoGetField);
|
||||
REGISTER_API(ServerInfoGetFieldC);
|
||||
REGISTER_API(ServerInfoGetFieldNumerical);
|
||||
REGISTER_API(ServerInfoGetFieldDouble);
|
||||
REGISTER_API(GetClientInfoById);
|
||||
|
@ -506,8 +506,9 @@ int REDISMODULE_API_FUNC(RedisModule_InfoAddFieldULongLong)(RedisModuleInfoCtx *
|
||||
RedisModuleServerInfoData *REDISMODULE_API_FUNC(RedisModule_GetServerInfo)(RedisModuleCtx *ctx, const char *section);
|
||||
void REDISMODULE_API_FUNC(RedisModule_FreeServerInfo)(RedisModuleCtx *ctx, RedisModuleServerInfoData *data);
|
||||
RedisModuleString *REDISMODULE_API_FUNC(RedisModule_ServerInfoGetField)(RedisModuleCtx *ctx, RedisModuleServerInfoData *data, const char* field);
|
||||
long long REDISMODULE_API_FUNC(RedisModule_ServerInfoGetFieldNumerical)(RedisModuleCtx *ctx, RedisModuleServerInfoData *data, const char* field, int *out_err);
|
||||
double REDISMODULE_API_FUNC(RedisModule_ServerInfoGetFieldDouble)(RedisModuleCtx *ctx, RedisModuleServerInfoData *data, const char* field, int *out_err);
|
||||
const char *REDISMODULE_API_FUNC(RedisModule_ServerInfoGetFieldC)(RedisModuleServerInfoData *data, const char* field);
|
||||
long long REDISMODULE_API_FUNC(RedisModule_ServerInfoGetFieldNumerical)(RedisModuleServerInfoData *data, const char* field, int *out_err);
|
||||
double REDISMODULE_API_FUNC(RedisModule_ServerInfoGetFieldDouble)(RedisModuleServerInfoData *data, const char* field, int *out_err);
|
||||
int REDISMODULE_API_FUNC(RedisModule_SubscribeToServerEvent)(RedisModuleCtx *ctx, RedisModuleEvent event, RedisModuleEventCallback callback);
|
||||
RedisModuleBlockedClient *REDISMODULE_API_FUNC(RedisModule_BlockClientOnKeys)(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), long long timeout_ms, RedisModuleString **keys, int numkeys, void *privdata);
|
||||
void REDISMODULE_API_FUNC(RedisModule_SignalKeyAsReady)(RedisModuleCtx *ctx, RedisModuleString *key);
|
||||
@ -713,6 +714,7 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int
|
||||
REDISMODULE_GET_API(GetServerInfo);
|
||||
REDISMODULE_GET_API(FreeServerInfo);
|
||||
REDISMODULE_GET_API(ServerInfoGetField);
|
||||
REDISMODULE_GET_API(ServerInfoGetFieldC);
|
||||
REDISMODULE_GET_API(ServerInfoGetFieldNumerical);
|
||||
REDISMODULE_GET_API(ServerInfoGetFieldDouble);
|
||||
REDISMODULE_GET_API(GetClientInfoById);
|
||||
|
Reference in New Issue
Block a user