Class: RedisLocker::Locker
- Inherits:
-
Object
- Object
- RedisLocker::Locker
show all
- Defined in:
- lib/redis_locker/locker.rb
Constant Summary
collapse
- NULL_SET_VALUE =
-420
Instance Method Summary
collapse
Constructor Details
#initialize(*_args) ⇒ Locker
Returns a new instance of Locker.
4
5
6
7
8
9
10
11
12
|
# File 'lib/redis_locker/locker.rb', line 4
def initialize(*_args)
raise Errors::KeyStringNotSet unless @key_string.is_a?(String)
setup_redis_set
loop do
@instance_hash = rand(36**8).to_s(36)
break unless redis.sismember(@key_string, @instance_hash)
end
end
|
Instance Method Details
#lock ⇒ Object
14
15
16
|
# File 'lib/redis_locker/locker.rb', line 14
def lock
raise NotImplementedError, '#lock has to be implemented'
end
|
#lock! ⇒ Object
18
19
20
|
# File 'lib/redis_locker/locker.rb', line 18
def lock!
raise NotImplementedError, '#lock! has to be implemented'
end
|
#locked? ⇒ Boolean
22
23
24
|
# File 'lib/redis_locker/locker.rb', line 22
def locked?
raise NotImplementedError, '#locked? has to be implemented'
end
|
#unlock ⇒ Object
26
27
28
|
# File 'lib/redis_locker/locker.rb', line 26
def unlock
raise NotImplementedError, '#unlock has to be implemented'
end
|
#with_redis_lock(strategy: RedisLocker::DEFAULT_STRATEGY, retry_count: RedisLocker::DEFAULT_RETRY_COUNT, retry_interval: RedisLocker::DEFAULT_RETRY_INTERVAL, &block) ⇒ Object