class RailsIdle::Storage::RailsCache
Public Instance Methods
add(path, execution_time = nil)
click to toggle source
Calls superclass method
RailsIdle::Storage::Base#add
# File lib/rails-idle/storage/rails_cache.rb, line 5 def add(path, execution_time = nil) super if execution_time increment(path, COUNTER_KEY) increment(path, EXECUTION_KEY, (execution_time * 1000).round) end end
get(path, key)
click to toggle source
# File lib/rails-idle/storage/rails_cache.rb, line 13 def get(path, key) begin Rails.cache.read build_name(path, key) rescue Exception => e # Redis workaround (Rails.cache.read build_name(path, key), raw: true).to_i end end
reset(path)
click to toggle source
# File lib/rails-idle/storage/rails_cache.rb, line 21 def reset(path) [COUNTER_KEY, EXECUTION_KEY].each do |key| Rails.cache.delete build_name(path, key) end end
Private Instance Methods
build_name(path, key)
click to toggle source
# File lib/rails-idle/storage/rails_cache.rb, line 33 def build_name(path, key) "#{RailsIdle}.#{path}.#{key}" end
increment(path, key, amount = 1)
click to toggle source
# File lib/rails-idle/storage/rails_cache.rb, line 29 def increment(path, key, amount = 1) Rails.cache.increment build_name(path, key), amount end