module Counter::Cache::Credis::ClassMethods
Public Instance Methods
counter_cache_redis(options = {})
click to toggle source
# File lib/counter/cache/credis/counter.rb, line 19 def counter_cache_redis(options = {}) mattr_accessor :column_delay delay = options[:delay] || 20 column = options[:column] || 'views_count' self.column_delay = {} if self.column_delay.nil? self.column_delay[column] = delay defind_column_getter(column) include Counter::Cache::Credis::InstanceMethods end
defind_column_getter(column)
click to toggle source
# File lib/counter/cache/credis/counter.rb, line 11 def defind_column_getter(column) self.class_eval do define_method("get_#{column}_cache") do self.send(column) + RedisCli.new.get("#{self.class.table_name}/#{column}#{self.id}").to_i end end end