view t/stats.t~ @ 2:e28ab6bd21fa

Append/prepend commands. Introduce new storage commands "append" and "prepend" for atomic value modification. They follow generic storage commands interface as described in doc/protocol.txt: <command name> <key> <flags> <exptime> <bytes>\r\n <data block>\r\n Current implementation involves memcpy() twice to combine values on writing (i.e. full resulting value are copied), but truly atomic (and even threadsafe).
author Maxim Dounin <mdounin@mdounin.ru>
date Sun, 30 Sep 2007 04:14:57 +0400
parents 30782bb1fc04
children
line wrap: on
line source

#!/usr/bin/perl

use strict;
use Test::More tests => 8;
use FindBin qw($Bin);
use lib "$Bin/lib";
use MemcachedTest;

my $server = new_memcached();
my $sock = $server->sock;


## Output looks like this:
##
## STAT pid 16293
## STAT uptime 7
## STAT time 1174419597
## STAT version 1.2.1
## STAT pointer_size 32
## STAT rusage_user 0.012998
## STAT rusage_system 0.119981
## STAT curr_items 0
## STAT total_items 0
## STAT bytes 0
## STAT curr_connections 1
## STAT total_connections 2
## STAT connection_structures 2
## STAT cmd_get 0
## STAT cmd_set 0
## STAT get_hits 0
## STAT get_misses 0
## STAT bytes_read 7
## STAT bytes_written 0
## STAT limit_maxbytes 67108864

my $stats = mem_stats($sock);

# Test number of keys
is(scalar(keys(%$stats)), 20, "20 stats values");

# Test initial state
foreach my $key (qw(curr_items total_items bytes cmd_get cmd_set get_hits get_misses bytes_written)) {
    is($stats->{$key}, 0, "initial $key is zero");
}

# Do some operations
print $sock "get fooble\r\n";
print <$sock>;
my $stats = mem_stats($sock);
use Data::Dumper;
print Data::Dumper::Dumper($stats);