"Fossies" - the Fresh Open Source Software Archive

Member "memcached-1.6.15/t/getandtouch.t" (16 Jul 2020, 1355 Bytes) of package /linux/www/memcached-1.6.15.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/perl
    2 
    3 use strict;
    4 use warnings;
    5 use Test::More tests => 15;
    6 use FindBin qw($Bin);
    7 use lib "$Bin/lib";
    8 use MemcachedTest;
    9 
   10 
   11 my $server = new_memcached();
   12 my $sock = $server->sock;
   13 
   14 # cache miss
   15 print $sock "gat 10 foo1\r\n";
   16 is(scalar <$sock>, "END\r\n", "cache miss");
   17 
   18 # set foo1 and foo2 (and should get it)
   19 print $sock "set foo1 0 2 7\r\nfooval1\r\n";
   20 is(scalar <$sock>, "STORED\r\n", "stored foo");
   21 
   22 print $sock "set foo2 0 2 7\r\nfooval2\r\n";
   23 is(scalar <$sock>, "STORED\r\n", "stored foo2");
   24 
   25 # get and touch it with cas
   26 print $sock "gats 10 foo1 foo2\r\n";
   27 ok(scalar <$sock> =~ /VALUE foo1 0 7 (\d+)\r\n/, "get and touch foo1 with cas regexp success");
   28 is(scalar <$sock>, "fooval1\r\n","value");
   29 ok(scalar <$sock> =~ /VALUE foo2 0 7 (\d+)\r\n/, "get and touch foo2 with cas regexp success");
   30 is(scalar <$sock>, "fooval2\r\n","value");
   31 is(scalar <$sock>, "END\r\n", "end");
   32 
   33 # get and touch it without cas
   34 print $sock "gat 10 foo1 foo2\r\n";
   35 ok(scalar <$sock> =~ /VALUE foo1 0 7\r\n/, "get and touch foo1 without cas regexp success");
   36 is(scalar <$sock>, "fooval1\r\n","value");
   37 ok(scalar <$sock> =~ /VALUE foo2 0 7\r\n/, "get and touch foo2 without cas regexp success");
   38 is(scalar <$sock>, "fooval2\r\n","value");
   39 is(scalar <$sock>, "END\r\n", "end");
   40 
   41 sleep 2;
   42 mem_get_is($sock, "foo1", "fooval1");
   43 mem_get_is($sock, "foo2", "fooval2");