41 lines
1.4 KiB
Plaintext
41 lines
1.4 KiB
Plaintext
start_server {tags {"flash"} overrides {"storage-provider flash /mnt/tmp/"}} {
|
|
test "Without maxmemory small integers are shared" {
|
|
r config set maxmemory 0
|
|
r set a 1
|
|
assert {[r object refcount a] > 1}
|
|
}
|
|
|
|
foreach policy {
|
|
allkeys-random allkeys-lru allkeys-lfu
|
|
} {
|
|
test "maxmemory - is the memory limit honoured? (policy $policy)" {
|
|
# make sure to start with a blank instance
|
|
r flushall
|
|
# Get the current memory limit and calculate a new limit.
|
|
# We just add 100k to the current memory size so that it is
|
|
# fast for us to reach that limit.
|
|
set used [s used_memory]
|
|
set limit [expr {$used+100000*1024}]
|
|
r config set maxmemory $limit
|
|
r config set maxmemory-policy $policy
|
|
# Now add keys until the limit is almost reached.
|
|
set numkeys 0
|
|
while 1 {
|
|
r setex [randomKey] 10000 x
|
|
incr numkeys
|
|
if {[s used_memory]+4096 > $limit} {
|
|
assert {$numkeys > 10}
|
|
break
|
|
}
|
|
}
|
|
# If we add the same number of keys already added again, we
|
|
# should still be under the limit.
|
|
for {set j 0} {$j < $numkeys} {incr j} {
|
|
r setex [randomKey] 10000 x
|
|
}
|
|
assert {[s used_memory] < ($limit+4096)}
|
|
}
|
|
}
|
|
}
|
|
|