class Counter::Cache::Redis

Public Instance Methods

decr(key, val = 1) click to toggle source
# File lib/counter/cache/redis.rb, line 10
def decr(key, val = 1)
  with_redis do |redis|
    redis.decrby(key, val)
  end
end
del(key) click to toggle source
# File lib/counter/cache/redis.rb, line 22
def del(key)
  with_redis do |redis|
    redis.del(key)
  end
end
get(key) click to toggle source
# File lib/counter/cache/redis.rb, line 16
def get(key)
  with_redis do |redis|
    redis.get(key)
  end
end
incr(key, val = 1) click to toggle source
# File lib/counter/cache/redis.rb, line 4
def incr(key, val = 1)
  with_redis do |redis|
    redis.incrby key, val
  end
end

Private Instance Methods

with_redis() { |redis_pool| ... } click to toggle source
# File lib/counter/cache/redis.rb, line 30
def with_redis
  redis_pool = Counter::Cache.configuration.redis_pool
  return yield redis_pool unless redis_pool.respond_to?(:with)

  redis_pool.with do |redis|
    yield redis
  end
end