Method: RedisBackend#retrieve_counts

Defined in:
lib/counter_server.rb

#retrieve_counts(group_name) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/counter_server.rb', line 94

def retrieve_counts(group_name)
  ret = ActiveSupport::OrderedHash.new

  # The return value of zrangebyscore looks like this:
  # ["key 1", "1", "key 2", "4", "key 3", "100"]
  counts_array = @redis_client.zrangebyscore(group_name, '-inf', '+inf', :with_scores => true)
  counts_array.reverse.each_slice(2) do |pageviews, key|
    ret[key] = pageviews.to_i
  end
  ret
end