instance method
stats
Ruby on Rails 2.3.18
Since v2.2.3 Last seen in v2.3.18Available in: v2.2.3 v2.3.18
Signature
stats()
Returns statistics for each memcached server. An explanation of the statistics can be found in the memcached docs:
code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt
Example:
>> pp CACHE.stats
{"localhost:11211"=>
{"bytes"=>4718,
"pid"=>20188,
"connection_structures"=>4,
"time"=>1162278121,
"pointer_size"=>32,
"limit_maxbytes"=>67108864,
"cmd_get"=>14532,
"version"=>"1.2.0",
"bytes_written"=>432583,
"cmd_set"=>32,
"get_misses"=>0,
"total_connections"=>19,
"curr_connections"=>3,
"curr_items"=>4,
"uptime"=>1557,
"get_hits"=>14532,
"total_items"=>32,
"rusage_system"=>0.313952,
"rusage_user"=>0.119981,
"bytes_read"=>190619}}
=> nil
Source
# File activesupport/lib/active_support/vendor/memcache-client-1.7.4/memcache.rb, line 564
def stats
raise MemCacheError, "No active servers" unless active?
server_stats = {}
@servers.each do |server|
next unless server.alive?
with_socket_management(server) do |socket|
value = nil
socket.write "stats\r\n"
stats = {}
while line = socket.gets do
raise_on_error_response! line
break if line == "END\r\n"
if line =~ /\ASTAT ([\S]+) ([\w\.\:]+)/ then
name, value = $1, $2
stats[name] = case name
when 'version'
value
when 'rusage_user', 'rusage_system' then
seconds, microseconds = value.split(/:/, 2)
microseconds ||= 0
Float(seconds) + (Float(microseconds) / 1_000_000)
else
if value =~ /\A\d+\Z/ then
value.to_i
else
value
end
end
end
end
server_stats["#{server.host}:#{server.port}"] = stats
end
end
raise MemCacheError, "No active servers" if server_stats.empty?
server_stats
end
Defined in activesupport/lib/active_support/vendor/memcache-client-1.7.4/memcache.rb line 564
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in MemCache