0
|
1 #!/usr/bin/perl
|
|
2
|
|
3 use strict;
|
|
4 use Test::More tests => 10;
|
|
5 use FindBin qw($Bin);
|
|
6 use lib "$Bin/lib";
|
|
7 use MemcachedTest;
|
|
8
|
|
9 my $server = new_memcached();
|
|
10 my $sock = $server->sock;
|
|
11 my $expire;
|
|
12
|
|
13 print $sock "set foo 0 0 6\r\nfooval\r\n";
|
|
14 is(scalar <$sock>, "STORED\r\n", "stored foo");
|
|
15
|
|
16 mem_get_is($sock, "foo", "fooval");
|
|
17 print $sock "flush_all\r\n";
|
|
18 is(scalar <$sock>, "OK\r\n", "did flush_all");
|
|
19 mem_get_is($sock, "foo", undef);
|
|
20
|
|
21 # check that flush_all doesn't blow away items that immediately get set
|
|
22 print $sock "set foo 0 0 3\r\nnew\r\n";
|
|
23 is(scalar <$sock>, "STORED\r\n", "stored foo = 'new'");
|
|
24 mem_get_is($sock, "foo", 'new');
|
|
25
|
|
26 # and the other form, specifying a flush_all time...
|
|
27 my $expire = time() + 2;
|
|
28 print $sock "flush_all $expire\r\n";
|
|
29 is(scalar <$sock>, "OK\r\n", "did flush_all in future");
|
|
30
|
|
31 print $sock "set foo 0 0 4\r\n1234\r\n";
|
|
32 is(scalar <$sock>, "STORED\r\n", "stored foo = '1234'");
|
|
33 mem_get_is($sock, "foo", '1234');
|
|
34 sleep(2.2);
|
|
35 mem_get_is($sock, "foo", undef);
|