summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-07-18 10:55:08 +0200
committerantirez <antirez@gmail.com>2014-07-18 12:20:56 +0200
commite236199be84e1c6d215f5aba84bd8fbdf6758b0b (patch)
tree283e45142503caafe3fda63c35379b54018edd74
parent29e1c431bde04bee79924e437b314a26eed898a0 (diff)
downloadredis-e236199be84e1c6d215f5aba84bd8fbdf6758b0b.tar.gz
Test: small integer sharing depends on maxmemory policy.
-rw-r--r--tests/unit/maxmemory.tcl24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/unit/maxmemory.tcl b/tests/unit/maxmemory.tcl
index 2cde1d830..1431a2ac7 100644
--- a/tests/unit/maxmemory.tcl
+++ b/tests/unit/maxmemory.tcl
@@ -1,4 +1,28 @@
start_server {tags {"maxmemory"}} {
+ test "Without maxmemory small integers are shared" {
+ r config set maxmemory 0
+ r set a 1
+ assert {[r object refcount a] > 1}
+ }
+
+ test "With maxmemory and non-LRU policy integers are still shared" {
+ r config set maxmemory 1073741824
+ r config set maxmemory-policy allkeys-random
+ r set a 1
+ assert {[r object refcount a] > 1}
+ }
+
+ test "With maxmemory and LRU policy integers are not shared" {
+ r config set maxmemory 1073741824
+ r config set maxmemory-policy allkeys-lru
+ r set a 1
+ r config set maxmemory-policy volatile-lru
+ r set b 1
+ assert {[r object refcount a] == 1}
+ assert {[r object refcount b] == 1}
+ r config set maxmemory 0
+ }
+
foreach policy {
allkeys-random allkeys-lru volatile-lru volatile-random volatile-ttl
} {