lib/memcached/memcached.rb
def stats
    stats = Hash.new([])

    stat_struct, ret = Lib.memcached_stat(@struct, "")
    check_return_code(ret)

    keys, ret = Lib.memcached_stat_get_keys(@struct, stat_struct)
    check_return_code(ret)

    keys.each do |key|
       server_structs.size.times do |index|

         value, ret = Lib.memcached_stat_get_rvalue(
           @struct,
           Lib.memcached_select_stat_at(@struct, stat_struct, index),
           key)
         check_return_code(ret, key)

         value = case value
           when /^\d+\.\d+$/ then value.to_f
           when /^\d+$/ then value.to_i
           else value
         end

         stats[key.to_sym] += [value]
       end
    end

    Lib.memcached_stat_free(@struct, stat_struct)
    stats
  rescue Memcached::SomeErrorsWereReported => _
    e = _.class.new("Error getting stats")
    e.set_backtrace(_.backtrace)
    raise e
  end
# Return a Hash of statistics responses from the set of servers. Each value is an array with one entry for each server, in the same order the servers were defined.
Return a Hash of statistics responses from the set of servers. Each value is an array with one entry for each server, in the same order the servers were defined.
Return a Hash of statistics responses from the set of servers . Each value is an array with one entry for each server in the same order the servers were defined .
def stats
    stats = Hash.new([])
    stat_struct, ret = Lib.memcached_stat(@struct, "")
    check_return_code(ret)
    keys, ret = Lib.memcached_stat_get_keys(@struct, stat_struct)
    check_return_code(ret)
    keys.each do |key|
       server_structs.size.times do |index|
         value, ret = Lib.memcached_stat_get_rvalue(
           @struct,
           Lib.memcached_select_stat_at(@struct, stat_struct, index),
           key)
         check_return_code(ret, key)
         value = case value
           when /^\d+\.\d+$/ then value.to_f
           when /^\d+$/ then value.to_i
           else value
         end
         stats[key.to_sym] += [value]
       end
    end
    Lib.memcached_stat_free(@struct, stat_struct)
    stats
  rescue Memcached::SomeErrorsWereReported => _
    e = _.class.new("Error getting stats")
    e.set_backtrace(_.backtrace)
    raise e
  end
def stats stats = Hash . new ( [ ] ) stat_struct , ret = Lib . memcached_stat ( @struct , "" ) check_return_code ( ret ) keys , ret = Lib . memcached_stat_get_keys ( @struct , stat_struct ) check_return_code ( ret ) keys . each do | key | server_structs . size . times do | index | value , ret = Lib . memcached_stat_get_rvalue ( @struct , Lib . memcached_select_stat_at ( @struct , stat_struct , index ) , key ) check_return_code ( ret , key ) value = case value when / ^ \d + \. \d +$ / then value . to_f when / ^ \d +$ / then value . to_i else value end stats [ key . to_sym ] += [ value ] end end Lib . memcached_stat_free ( @struct , stat_struct ) stats rescue Memcached :: SomeErrorsWereReported => _ e = _ . class . new ( "Error getting stats" ) e . set_backtrace ( _ . backtrace ) raise e end
Return a Hash of statistics responses from the set of servers.
Return a Hash of statistics responses from the set of servers .