Method: Memcache#with_lock

Defined in:
lib/memcache.rb

#with_lock(key, opts = {}) ⇒ Object



295
296
297
298
299
300
301
302
303
# File 'lib/memcache.rb', line 295

def with_lock(key, opts = {})
  until lock(key) do
    return if opts[:ignore]
    sleep(WRITE_LOCK_WAIT) # just wait
  end
  yield
ensure
  unlock(key) unless opts[:keep]
end