mirror of
https://github.com/fluencelabs/redis
synced 2025-07-02 18:31:34 +00:00
Merge branch 'unstable' of github.com:/antirez/redis into unstable
This commit is contained in:
24
src/module.c
24
src/module.c
@ -7310,22 +7310,30 @@ int RM_GetLFU(RedisModuleKey *key, long long *lfu_freq) {
|
||||
* Unlike RM_ModuleTypeSetValue() which will free the old value, this function
|
||||
* simply swaps the old value with the new value.
|
||||
*
|
||||
* The function returns the old value, or NULL if any of the above conditions is
|
||||
* not met.
|
||||
* The function returns REDISMODULE_OK on success, REDISMODULE_ERR on errors
|
||||
* such as:
|
||||
*
|
||||
* 1. Key is not opened for writing.
|
||||
* 2. Key is not a module data type key.
|
||||
* 3. Key is a module datatype other than 'mt'.
|
||||
*
|
||||
* If old_value is non-NULL, the old value is returned by reference.
|
||||
*/
|
||||
void *RM_ModuleTypeReplaceValue(RedisModuleKey *key, moduleType *mt, void *new_value) {
|
||||
int RM_ModuleTypeReplaceValue(RedisModuleKey *key, moduleType *mt, void *new_value, void **old_value) {
|
||||
if (!(key->mode & REDISMODULE_WRITE) || key->iter)
|
||||
return NULL;
|
||||
return REDISMODULE_ERR;
|
||||
if (!key->value || key->value->type != OBJ_MODULE)
|
||||
return NULL;
|
||||
return REDISMODULE_ERR;
|
||||
|
||||
moduleValue *mv = key->value->ptr;
|
||||
if (mv->type != mt)
|
||||
return NULL;
|
||||
return REDISMODULE_ERR;
|
||||
|
||||
void *old_val = mv->value;
|
||||
if (old_value)
|
||||
*old_value = mv->value;
|
||||
mv->value = new_value;
|
||||
return old_val;
|
||||
|
||||
return REDISMODULE_OK;
|
||||
}
|
||||
|
||||
/* Register all the APIs we export. Keep this function at the end of the
|
||||
|
@ -525,7 +525,7 @@ int REDISMODULE_API_FUNC(RedisModule_GetContextFlags)(RedisModuleCtx *ctx);
|
||||
void *REDISMODULE_API_FUNC(RedisModule_PoolAlloc)(RedisModuleCtx *ctx, size_t bytes);
|
||||
RedisModuleType *REDISMODULE_API_FUNC(RedisModule_CreateDataType)(RedisModuleCtx *ctx, const char *name, int encver, RedisModuleTypeMethods *typemethods);
|
||||
int REDISMODULE_API_FUNC(RedisModule_ModuleTypeSetValue)(RedisModuleKey *key, RedisModuleType *mt, void *value);
|
||||
void *REDISMODULE_API_FUNC(RedisModule_ModuleTypeReplaceValue)(RedisModuleKey *key, RedisModuleType *mt, void *new_value);
|
||||
int REDISMODULE_API_FUNC(RedisModule_ModuleTypeReplaceValue)(RedisModuleKey *key, RedisModuleType *mt, void *new_value, void **old_value);
|
||||
RedisModuleType *REDISMODULE_API_FUNC(RedisModule_ModuleTypeGetType)(RedisModuleKey *key);
|
||||
void *REDISMODULE_API_FUNC(RedisModule_ModuleTypeGetValue)(RedisModuleKey *key);
|
||||
int REDISMODULE_API_FUNC(RedisModule_IsIOError)(RedisModuleIO *io);
|
||||
|
@ -999,7 +999,7 @@ struct redisCommand redisCommandTable[] = {
|
||||
0,NULL,0,0,0,0,0,0},
|
||||
|
||||
{"acl",aclCommand,-2,
|
||||
"admin no-script ok-loading ok-stale",
|
||||
"admin no-script no-slowlog ok-loading ok-stale",
|
||||
0,NULL,0,0,0,0,0,0}
|
||||
};
|
||||
|
||||
@ -2266,6 +2266,7 @@ void createSharedObjects(void) {
|
||||
void initServerConfig(void) {
|
||||
int j;
|
||||
|
||||
server.hz = CONFIG_DEFAULT_HZ;
|
||||
updateCachedTime(1);
|
||||
getRandomHexChars(server.runid,CONFIG_RUN_ID_SIZE);
|
||||
server.runid[CONFIG_RUN_ID_SIZE] = '\0';
|
||||
|
Reference in New Issue
Block a user