Sha256: d4949114c8dbd3510fe7fdbb361827df9d073bd3725e69a2c7cefa77c7af816a

Contents?: true

Size: 411 Bytes

Versions: 4

Compression:

Stored size: 411 Bytes

Contents

class Kredis::Types::Counter < Kredis::Types::Proxying
  proxying :multi, :set, :incrby, :decrby, :get, :del

  attr_accessor :expires_in

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

  def decrement(by: 1)
    multi do
      set 0, ex: expires_in, nx: true
      decrby by
    end
  end

  def value
    get.to_i
  end

  def reset
    del
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kredis-0.4.0 lib/kredis/types/counter.rb
kredis-0.3.1 lib/kredis/types/counter.rb
kredis-0.3.0 lib/kredis/types/counter.rb
kredis-0.2.3 lib/kredis/types/counter.rb