mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 08:38:27 -05:00
1df5bb5687
One way this was happening is when a module issued an RM_Call which would inject MULTI. If the module command that does that was itself issued by something else that already did added MULTI (e.g. another module, or a Lua script), it would have caused nested MULTI. In fact the MULTI state in the client or the MULTI_EMITTED flag in the context isn't the right indication that we need to propagate MULTI or not, because on a nested calls (possibly a module action called by a keyspace event of another module action), these flags aren't retained / reflected. instead there's now a global propagate_in_transaction flag for that. in addition to that, we now have a global in_eval and in_exec flags, to serve the flags of RM_GetContextFlags, since their dependence on the current client is wrong for the same reasons mentioned above.
72 lines
2.1 KiB
Tcl
72 lines
2.1 KiB
Tcl
set testmodule [file normalize tests/modules/keyspace_events.so]
|
|
|
|
tags "modules" {
|
|
start_server [list overrides [list loadmodule "$testmodule"]] {
|
|
|
|
test {Test loaded key space event} {
|
|
r set x 1
|
|
r hset y f v
|
|
r lpush z 1 2 3
|
|
r sadd p 1 2 3
|
|
r zadd t 1 f1 2 f2
|
|
r xadd s * f v
|
|
r debug reload
|
|
assert_equal {1 x} [r keyspace.is_key_loaded x]
|
|
assert_equal {1 y} [r keyspace.is_key_loaded y]
|
|
assert_equal {1 z} [r keyspace.is_key_loaded z]
|
|
assert_equal {1 p} [r keyspace.is_key_loaded p]
|
|
assert_equal {1 t} [r keyspace.is_key_loaded t]
|
|
assert_equal {1 s} [r keyspace.is_key_loaded s]
|
|
}
|
|
|
|
test {Nested multi due to RM_Call} {
|
|
r del multi
|
|
r del lua
|
|
|
|
r set x 1
|
|
r set x_copy 1
|
|
r keyspace.del_key_copy x
|
|
r keyspace.incr_case1 x
|
|
r keyspace.incr_case2 x
|
|
r keyspace.incr_case3 x
|
|
assert_equal {} [r get multi]
|
|
assert_equal {} [r get lua]
|
|
r get x
|
|
} {3}
|
|
|
|
test {Nested multi due to RM_Call, with client MULTI} {
|
|
r del multi
|
|
r del lua
|
|
|
|
r set x 1
|
|
r set x_copy 1
|
|
r multi
|
|
r keyspace.del_key_copy x
|
|
r keyspace.incr_case1 x
|
|
r keyspace.incr_case2 x
|
|
r keyspace.incr_case3 x
|
|
r exec
|
|
assert_equal {1} [r get multi]
|
|
assert_equal {} [r get lua]
|
|
r get x
|
|
} {3}
|
|
|
|
test {Nested multi due to RM_Call, with EVAL} {
|
|
r del multi
|
|
r del lua
|
|
|
|
r set x 1
|
|
r set x_copy 1
|
|
r eval {
|
|
redis.pcall('keyspace.del_key_copy', KEYS[1])
|
|
redis.pcall('keyspace.incr_case1', KEYS[1])
|
|
redis.pcall('keyspace.incr_case2', KEYS[1])
|
|
redis.pcall('keyspace.incr_case3', KEYS[1])
|
|
} 1 x
|
|
assert_equal {} [r get multi]
|
|
assert_equal {1} [r get lua]
|
|
r get x
|
|
} {3}
|
|
}
|
|
}
|