1 start_server
{tags
{"archive"}} {
3 test
"archive - can archived keys be recovered?" {
4 # make sure to start with a blank instance
6 # Turn on our key archival system
7 r config
set keyarchive yes
8 # Get the current memory limit and calculate a new limit.
9 # We just add 100k to the current memory size so that it is
10 # fast for us to reach that limit.
11 set used
[s used_memory
]
12 set limit
[expr {$used+100*1024}]
13 r config
set maxmemory
$limit
14 r config
set maxmemory-policy allkeys-random
15 # Now add keys until the limit is almost reached.
18 # Odd keys are volatile
19 # Even keys are non volatile
21 r setex
"key:$numkeys" 10000 x
23 r
set "key:$numkeys" x
25 if {[s used_memory
]+4096 > $limit} {
26 assert
{$numkeys > 10}
31 # If we add the same number of keys already added again, we
32 # should still be under the limit.
33 for {set j
0} {$j < $numkeys} {incr j
} {
34 r setex
[randomKey
] 10000 x
36 assert
{[s used_memory
] < ($limit+4096)}
37 # However all our non volatile keys should be here.
38 for {set j
0} {$j < $numkeys} {incr j
2} {
39 assert
{[r exists
"key:$j"]}