diff -rup memcached-1.2.1/items.c memcached-1.2.1-cachestats/items.c --- memcached-1.2.1/items.c 2006-12-05 10:34:10.000000000 +0100 +++ memcached-1.2.1-cachestats/items.c 2007-03-20 17:03:07.000000000 +0100 @@ -94,6 +94,8 @@ item *item_alloc(char *key, size_t nkey, for (search = tails[id]; tries>0 && search; tries--, search=search->prev) { if (search->refcount==0) { + if (search->exptime > current_time) + stats.evictions++; item_unlink(search); break; } diff -rup memcached-1.2.1/memcached.c memcached-1.2.1-cachestats/memcached.c --- memcached-1.2.1/memcached.c 2006-12-05 10:34:10.000000000 +0100 +++ memcached-1.2.1-cachestats/memcached.c 2007-03-20 17:03:44.000000000 +0100 @@ -96,7 +96,7 @@ rel_time_t realtime(time_t exptime) { void stats_init(void) { stats.curr_items = stats.total_items = stats.curr_conns = stats.total_conns = stats.conn_structs = 0; - stats.get_cmds = stats.set_cmds = stats.get_hits = stats.get_misses = 0; + stats.get_cmds = stats.set_cmds = stats.get_hits = stats.get_misses = stats.evictions = 0; stats.curr_bytes = stats.bytes_read = stats.bytes_written = 0; /* make the time we started always be 2 seconds before we really @@ -108,7 +108,7 @@ void stats_init(void) { void stats_reset(void) { stats.total_items = stats.total_conns = 0; - stats.get_cmds = stats.set_cmds = stats.get_hits = stats.get_misses = 0; + stats.get_cmds = stats.set_cmds = stats.get_hits = stats.get_misses = stats.evictions = 0; stats.bytes_read = stats.bytes_written = 0; } @@ -761,6 +761,7 @@ void process_stat(conn *c, token_t* toke pos += sprintf(pos, "STAT cmd_set %llu\r\n", stats.set_cmds); pos += sprintf(pos, "STAT get_hits %llu\r\n", stats.get_hits); pos += sprintf(pos, "STAT get_misses %llu\r\n", stats.get_misses); + pos += sprintf(pos, "STAT evictions %llu\r\n", stats.evictions); pos += sprintf(pos, "STAT bytes_read %llu\r\n", stats.bytes_read); pos += sprintf(pos, "STAT bytes_written %llu\r\n", stats.bytes_written); pos += sprintf(pos, "STAT limit_maxbytes %llu\r\n", (unsigned long long) settings.maxbytes); diff -rup memcached-1.2.1/memcached.h memcached-1.2.1-cachestats/memcached.h --- memcached-1.2.1/memcached.h 2006-12-05 10:34:10.000000000 +0100 +++ memcached-1.2.1-cachestats/memcached.h 2007-03-20 16:55:21.000000000 +0100 @@ -35,6 +35,7 @@ struct stats { unsigned long long set_cmds; unsigned long long get_hits; unsigned long long get_misses; + unsigned long long evictions; time_t started; /* when the process was started */ unsigned long long bytes_read; unsigned long long bytes_written;