is a unique string identifying the object to lock, e.g. “user-1”
options(:life)(defaults to: {})
—
should be set, but defaults to 1 minute
options(:owner)(defaults to: {})
—
may be set, but defaults to HOSTNAME:PID
options(:sleep)(defaults to: {})
—
is used when trying to acquire the lock; milliseconds; defaults to 125.
options(:acquire)(defaults to: {})
—
defaults to 10 seconds and can be used to determine how long to wait for a lock.
229
230
231
232
233
234
235
# File 'lib/redis-lock.rb', line 229deflock(key,options={},&block)acquire=options.delete(:acquire)||10lock=Redis::Lock.newself,key,optionsblock_given??lock.lock(acquire,&block):lockend
#unlock(key) ⇒ Object
237
238
239
# File 'lib/redis-lock.rb', line 237defunlock(key)Redis::Lock.new(self,key).unlockend