class RouteCounter::RedisRecorder
Public Class Methods
action_visited(controller_name, action_name)
click to toggle source
# File lib/route_counter/redis_recorder.rb, line 34 def action_visited(controller_name, action_name) key = "#{controller_name}##{action_name}" increment!(key, 1) end
actions_visited()
click to toggle source
# File lib/route_counter/redis_recorder.rb, line 39 def actions_visited # returns what was visited and counts read_key(current_key) end
clear!()
click to toggle source
# File lib/route_counter/redis_recorder.rb, line 48 def clear! client.del(current_key) end
client()
click to toggle source
# File lib/route_counter/redis_recorder.rb, line 14 def client RouteCounter.config.redis end
current_key()
click to toggle source
# File lib/route_counter/redis_recorder.rb, line 18 def current_key "route_counter:current" end
increment!(action_key, amount)
click to toggle source
# File lib/route_counter/redis_recorder.rb, line 30 def increment!(action_key, amount) client.hincrby(current_key, action_key, amount) end
read_key(key)
click to toggle source
# File lib/route_counter/redis_recorder.rb, line 22 def read_key(key) out = {} client.hgetall(key).each do |action, num| out[action] = num.to_i end out end
rotate!()
click to toggle source
# File lib/route_counter/redis_recorder.rb, line 44 def rotate! raise "not supported" end