server/modules/selva/module/alias.c
void update_alias(RedisModuleCtx *ctx, RedisModuleKey *alias_key, RedisModuleString *id, RedisModuleString *ref) {
    RedisModuleString *orig = NULL;

    /*
     * Remove the alias from the previous node.
     */
    if (!RedisModule_HashGet(alias_key, REDISMODULE_HASH_NONE, ref, &orig, NULL)) {
        if (orig) {
            RedisModuleKey *key;

            key = RedisModule_OpenKey(ctx, orig, REDISMODULE_READ | REDISMODULE_WRITE);
            if (key) {
                struct SelvaObject *obj;

                if (SelvaObject_Key2Obj(key, &obj) == 0) {
                    SelvaObject_RemStringSetStr(obj, SELVA_ALIASES_FIELD, sizeof(SELVA_ALIASES_FIELD) - 1, ref);
                }
            }

            RedisModule_CloseKey(key);
        }
    }

    RedisModule_HashSet(alias_key, REDISMODULE_HASH_NONE, ref, id, NULL);
}
/*
 * Caller must set the alias to the new node.
 */
Caller must set the alias to the new node.
Caller must set the alias to the new node .
void update_alias(RedisModuleCtx *ctx, RedisModuleKey *alias_key, RedisModuleString *id, RedisModuleString *ref) {
    RedisModuleString *orig = NULL;
    if (!RedisModule_HashGet(alias_key, REDISMODULE_HASH_NONE, ref, &orig, NULL)) {
        if (orig) {
            RedisModuleKey *key;
            key = RedisModule_OpenKey(ctx, orig, REDISMODULE_READ | REDISMODULE_WRITE);
            if (key) {
                struct SelvaObject *obj;
                if (SelvaObject_Key2Obj(key, &obj) == 0) {
                    SelvaObject_RemStringSetStr(obj, SELVA_ALIASES_FIELD, sizeof(SELVA_ALIASES_FIELD) - 1, ref);
                }
            }
            RedisModule_CloseKey(key);
        }
    }
    RedisModule_HashSet(alias_key, REDISMODULE_HASH_NONE, ref, id, NULL);
}
void update_alias ( RedisModuleCtx * ctx , RedisModuleKey * alias_key , RedisModuleString * id , RedisModuleString * ref ) { RedisModuleString * orig = NULL ; if ( ! RedisModule_HashGet ( alias_key , REDISMODULE_HASH_NONE , ref , & orig , NULL ) ) { if ( orig ) { RedisModuleKey * key ; key = RedisModule_OpenKey ( ctx , orig , REDISMODULE_READ | REDISMODULE_WRITE ) ; if ( key ) { struct SelvaObject * obj ; if ( SelvaObject_Key2Obj ( key , & obj ) == 0 ) { SelvaObject_RemStringSetStr ( obj , SELVA_ALIASES_FIELD , sizeof ( SELVA_ALIASES_FIELD ) - 1 , ref ) ; } } RedisModule_CloseKey ( key ) ; } } RedisModule_HashSet ( alias_key , REDISMODULE_HASH_NONE , ref , id , NULL ) ; }
Caller must set the alias to the new node.
Caller must set the alias to the new node .
/*
     * Remove the alias from the previous node.
     */