Sha256: 71b21b711047eeec64ab8330b30f66af7984d5ff9cda0c557109191c8ef037e8

Contents?: true

Size: 653 Bytes

Versions: 3

Compression:

Stored size: 653 Bytes

Contents

# frozen_string_literal: true

module ActiveRedisStats
  module Count
    class Set < ActiveRedisStats::Count::Base

      class << self
        %i[decrement increment].each do |meth|
          define_method(meth) do |key, by: 1|
            ActiveRedisDB::String
              .send(meth, primary_key(key), by)
          end

          define_method("#{meth}_intervals") do |key, by: 1|
            ActiveRedisStats::Base::EXPIRES.each do |frmt, secs|
              ikey = "#{key}:#{interval_key(frmt)}"

              send(meth, ikey, by: by)
              expiration(ikey, secs)
            end
          end
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_redis_stats-0.1.3 lib/active_redis_stats/count/set.rb
active_redis_stats-0.1.2 lib/active_redis_stats/count/set.rb
active_redis_stats-0.1.1 lib/active_redis_stats/count/set.rb