Sha256: baf411d748cefb19531f26ddb5ffb5b79f5057b4024cdc5b77bc77a1e7cefbf4

Contents?: true

Size: 322 Bytes

Versions: 1

Compression:

Stored size: 322 Bytes

Contents

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

  def lock
    set 1, ex: @expires_in
  end

  def unlock
    del
  end

  def locked?
    get
  end

  def synchronize
    lock
    yield
  ensure
    unlock
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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