"Fossies" - the Fresh Open Source Software Archive

Member "memcached-1.6.15/t/evictions.t" (16 Jul 2020, 873 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 # Test the 'stats items' evictions counters.
    3 
    4 use strict;
    5 use Test::More tests => 92;
    6 use FindBin qw($Bin);
    7 use lib "$Bin/lib";
    8 use MemcachedTest;
    9 
   10 my $server = new_memcached("-m 3");
   11 my $sock = $server->sock;
   12 my $value = "B"x66560;
   13 my $key = 0;
   14 
   15 # These aren't set to expire.
   16 for ($key = 0; $key < 40; $key++) {
   17     print $sock "set key$key 0 0 66560\r\n$value\r\n";
   18     is(scalar <$sock>, "STORED\r\n", "stored key$key");
   19 }
   20 
   21 # These ones would expire in 600 seconds.
   22 for ($key = 0; $key < 50; $key++) {
   23     print $sock "set key$key 0 600 66560\r\n$value\r\n";
   24     is(scalar <$sock>, "STORED\r\n", "stored key$key");
   25 }
   26 
   27 my $stats  = mem_stats($sock, "items");
   28 my $evicted = $stats->{"items:31:evicted"};
   29 isnt($evicted, "0", "check evicted");
   30 my $evicted_nonzero = $stats->{"items:31:evicted_nonzero"};
   31 isnt($evicted_nonzero, "0", "check evicted_nonzero");