Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Issue 104: stats bug for cmd_get

  • Loading branch information...
commit b1001be042a5b078bfc00a87fec1467f12045323 1 parent ac37e81
Trond Norbye authored dustin committed
Showing with 25 additions and 0 deletions.
  1. +1 −0  memcached.c
  2. +24 −0 t/issue_104.t
View
1  memcached.c
@@ -2618,6 +2618,7 @@ static inline void process_get_command(conn *c, token_t *tokens, size_t ntokens,
} else {
pthread_mutex_lock(&c->thread->stats.mutex);
c->thread->stats.get_misses++;
+ c->thread->stats.get_cmds++;
pthread_mutex_unlock(&c->thread->stats.mutex);
MEMCACHED_COMMAND_GET(c->sfd, key, nkey, -1, 0);
}
View
24 t/issue_104.t
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+use strict;
+use Test::More tests => 6;
+use FindBin qw($Bin);
+use lib "$Bin/lib";
+use MemcachedTest;
+
+my $server = new_memcached();
+my $sock = $server->sock;
+
+# first get should miss
+print $sock "get foo\r\n";
+is(scalar <$sock>, "END\r\n", "get foo");
+
+# Now set and get (should hit)
+print $sock "set foo 0 0 6\r\nfooval\r\n";
+is(scalar <$sock>, "STORED\r\n", "stored foo");
+mem_get_is($sock, "foo", "fooval");
+
+my $stats = mem_stats($sock);
+is($stats->{cmd_get}, 2, "Should have 2 get requests");
+is($stats->{get_hits}, 1, "Should have 1 hit");
+is($stats->{get_misses}, 1, "Should have 1 miss");
Please sign in to comment.
Something went wrong with that request. Please try again.