The memcached system has a built-in statistics
system that collects information about the data being stored into
the cache, cache hit ratios, and detailed information on the
memory usage and distribution of information through the slab
allocation used to store individual items. Statistics are provided
at both a basic level that provide the core statistics, and more
specific statistics for specific areas of the
memcached server.

This information can be useful to ensure that you are getting the
correct level of cache and memory usage, and that your slab
allocation and configuration properties are set at an optimal
level.

When using Perl and the Cache::Memcached
module, the stats() function returns
information about all the servers currently configured in the
connection object, and total statistics for all the
memcached servers as a whole.

For example, the following Perl script obtains the stats and dumps
the hash reference that is returned:

The statistics are divided up into a number of distinct sections,
and then can be requested by adding the type to the
stats command. Each statistics output is
covered in more detail in the following sections.