Sha256: 5aee8a8e8e3e78759b851613dfbd571c8de9ae4c861b534e9527f793808a1568

Contents?: true

Size: 296 Bytes

Versions: 1

Compression:

Stored size: 296 Bytes

Contents

class Kredis::Types::Counter < Kredis::Types::Proxy
  def initialize(redis, key, expires_in: nil)
    @expires_in = expires_in
    super redis, key
  end

  def increment(by: 1)
    multi do
      set 0, ex: @expires_in, nx: true
      incrby by
    end
  end

  def value
    get.to_i
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kredis-0.1.2 lib/kredis/types/counter.rb