Sha256: f05e1a54a533abc04340566e143ea9b7b9724c0d6951ad53e686b0d94272cf10

Contents?: true

Size: 378 Bytes

Versions: 2

Compression:

Stored size: 378 Bytes

Contents

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

  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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kredis-0.2.2 lib/kredis/types/counter.rb
kredis-0.2.1 lib/kredis/types/counter.rb