Sha256: c67d006aac6b0a4180347d3b0864c94ad98bce64e33870c02d204e03d3db515f

Contents?: true

Size: 554 Bytes

Versions: 3

Compression:

Stored size: 554 Bytes

Contents

module Tally
  class Increment

    include Keyable

    def increment(by = 1)
      Tally.redis do |conn|
        conn.multi do
          conn.incrby(redis_key, by)
          conn.expire(redis_key, Tally.config.ttl) if Tally.config.ttl.present?

          conn.sadd(daily_key, simple_key)
          conn.expire(daily_key, Tally.config.ttl) if Tally.config.ttl.present?
        end
      end
    end

    def self.increment(key, record = nil, by = 1)
      instance = new(key, record)
      instance.increment(by)
      instance = nil
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tally-1.0.1 lib/tally/increment.rb
tally-1.0.0 lib/tally/increment.rb
tally-1.0.0.beta1 lib/tally/increment.rb