module RedisHash::Counters
Public Instance Methods
decrement(field, by: 1)
click to toggle source
# File lib/redis_hash/concerns/counters.rb, line 28 def decrement(field, by: 1) increment_field_by(field, by, modifier: -1) end
increment(field, by: 1)
click to toggle source
# File lib/redis_hash/concerns/counters.rb, line 24 def increment(field, by: 1) increment_field_by(field, by) end
increment_field_by(field, by, modifier: 1)
click to toggle source
# File lib/redis_hash/concerns/counters.rb, line 13 def increment_field_by(field, by, modifier: 1) raise ArgumentError, "by must be greater than or equal to 0" if by < 0 by *= modifier return hincrbyfloat(redis_key, field, by) if by.is_a?(Float) hincrby(redis_key, field, by) end