mirror of
https://github.com/fluencelabs/redis
synced 2025-03-30 22:31:03 +00:00
Test: check that INCR object sharing works as expected.
This commit is contained in:
parent
16559b4615
commit
389ec305b3
@ -150,6 +150,29 @@ start_server {tags {"basic"}} {
|
|||||||
r decrby novar 17179869185
|
r decrby novar 17179869185
|
||||||
} {-1}
|
} {-1}
|
||||||
|
|
||||||
|
test {INCR uses shared objects in the 0-9999 range} {
|
||||||
|
r set foo -1
|
||||||
|
r incr foo
|
||||||
|
assert {[r object refcount foo] > 1}
|
||||||
|
r set foo 9998
|
||||||
|
r incr foo
|
||||||
|
assert {[r object refcount foo] > 1}
|
||||||
|
r incr foo
|
||||||
|
assert {[r object refcount foo] == 1}
|
||||||
|
}
|
||||||
|
|
||||||
|
test {INCR can modify objects in-place} {
|
||||||
|
r set foo 20000
|
||||||
|
r incr foo
|
||||||
|
assert {[r object refcount foo] == 1}
|
||||||
|
set old [lindex [split [r debug object foo]] 1]
|
||||||
|
r incr foo
|
||||||
|
set new [lindex [split [r debug object foo]] 1]
|
||||||
|
assert {[string range $old 0 2] eq "at:"}
|
||||||
|
assert {[string range $new 0 2] eq "at:"}
|
||||||
|
assert {$old eq $new}
|
||||||
|
}
|
||||||
|
|
||||||
test {INCRBYFLOAT against non existing key} {
|
test {INCRBYFLOAT against non existing key} {
|
||||||
r del novar
|
r del novar
|
||||||
list [roundFloat [r incrbyfloat novar 1]] \
|
list [roundFloat [r incrbyfloat novar 1]] \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user