mirror of
https://github.com/redis/redis.git
synced 2026-10-28 08:25:04 +08:00
Trim BLESS notification regression test
This commit is contained in:
1 parent
02e50d0197
commit
2eb39e07d3
3 files changed
+6
-25
No files matched your search
+2
-8
@@ -7739,14 +7739,8 @@ int RM_ModuleTypeSetValue(RedisModuleKey *key, moduleType *mt, void *value) {
|
||||
RM_DeleteKey(key);
|
||||
robj *o = createModuleObject(mt,value);
|
||||
setKey(key->ctx->client,key->db,key->key, &o,SETKEY_NO_SIGNAL);
|
||||
/* Keyspace notification callbacks may reallocate the new kvobj by
|
||||
* attaching metadata, so don't use the pointer returned by setKey. */
|
||||
key->kv = dbFind(key->db, key->key->ptr);
|
||||
if (noevict && key->kv && key->kv->type == OBJ_MODULE) {
|
||||
moduleValue *mv = key->kv->ptr;
|
||||
if (mv->type == mt && mv->value == value && !blessIsNoEvict(key->kv))
|
||||
blessSetNoEvict(key->db, key->kv, 1);
|
||||
}
|
||||
key->kv = o;
|
||||
if (noevict) blessSetNoEvict(key->db, key->kv, 1);
|
||||
return REDISMODULE_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -128,10 +128,10 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
||||
if (meta_class_id < 0) return REDISMODULE_ERR;
|
||||
|
||||
/* Subscribe to keyspace events matching RediSearch's notification types:
|
||||
* GENERIC, NEW, HASH, STRING, EXPIRED, and EVICTED. */
|
||||
int notifyFlags = REDISMODULE_NOTIFY_GENERIC | REDISMODULE_NOTIFY_NEW |
|
||||
REDISMODULE_NOTIFY_HASH | REDISMODULE_NOTIFY_STRING |
|
||||
REDISMODULE_NOTIFY_EXPIRED | REDISMODULE_NOTIFY_EVICTED;
|
||||
* GENERIC, HASH, STRING, EXPIRED, and EVICTED. */
|
||||
int notifyFlags = REDISMODULE_NOTIFY_GENERIC | REDISMODULE_NOTIFY_HASH |
|
||||
REDISMODULE_NOTIFY_STRING | REDISMODULE_NOTIFY_EXPIRED |
|
||||
REDISMODULE_NOTIFY_EVICTED;
|
||||
if (RedisModule_SubscribeToKeyspaceEvents(ctx, notifyFlags,
|
||||
HashNotifyCallback) != REDISMODULE_OK)
|
||||
return REDISMODULE_ERR;
|
||||
|
||||
@@ -14,19 +14,6 @@ start_server {tags {"modules" "bless" "external:skip"}} {
|
||||
assert_equal 1 [s blessed_keys]
|
||||
}
|
||||
|
||||
test {BLESS: RM_ModuleTypeSetValue handles key metadata set by a notification} {
|
||||
set notify_module [file normalize tests/modules/keymeta_notify.so]
|
||||
r module load $notify_module
|
||||
r datatype.set notified 1 a
|
||||
r bless set notified no-evict
|
||||
r datatype.set notified 2 b
|
||||
assert_equal {2 b} [r datatype.get notified]
|
||||
assert_equal {notified} [r keymetanotify.get notified]
|
||||
assert_equal {NO-EVICT} [r bless get notified]
|
||||
assert_equal 1 [s blessed_keys]
|
||||
r module unload keymetanotify
|
||||
}
|
||||
|
||||
test {BLESS: blessed module key is not evicted after its value is replaced} {
|
||||
r flushall
|
||||
r config set maxmemory 0
|
||||
|
||||
Reference in new issue
Block a user