For memcached 1.3.x and higher, you can enable and obtain detailed statistics about the get, set, and del operations on theindividual keys stored in the cache, and determine whether the attempts hit (found) a particular key. These operations are only recorded while the detailed stats analysis is turned on.
To enable detailed statistics, you must send the stats
detail on
command to the memcached
server:
$ telnet localhost 11211
Trying 127.0.0.1...
Connected to tiger.
Escape character is '^]'.
stats detail on
OK
Individual statistics will be recorded for every
get
, set
and
del
operation on a key, including keys that
are not currently stored in the server. For example, if an
attempt is made to obtain the value of key
abckey
and it does not exist, the
get
operating on the specified key will be
recorded while detailed statistics are in effect, even if the
key is not currently stored. The hits
, that
is, the number of get
or
del
operations for a key that exists in the
server are also counted.
To turn detailed statistics off, send the stats detail
off
command to the memcached
server:
$ telnet localhost 11211
Trying 127.0.0.1...
Connected to tiger.
Escape character is '^]'.
stats detail on
OK
To obtain the detailed statistics recorded during the process,
send the stats detail dump
command to the
memcached server:
stats detail dump PREFIX hykkey get 0 hit 0 set 1 del 0 PREFIX xyzkey get 0 hit 0 set 1 del 0 PREFIX yukkey get 1 hit 0 set 0 del 0 PREFIX abckey get 3 hit 3 set 1 del 0 END
You can use the detailed statistics information to determine
whether your memcached clients are using a
large number of keys that do not exist in the server by
comparing the hit
and get
or del
counts. Because the information is
recorded by key, you can also determine whether the failures or
operations are clustered around specific keys.