Module: Circuitry::Locks::Base
Constant Summary collapse
- DEFAULT_SOFT_TTL =
5 minutes
(5 * 60).freeze
- DEFAULT_HARD_TTL =
24 hours
(24 * 60 * 60).freeze
Instance Attribute Summary collapse
-
#hard_ttl ⇒ Object
readonly
Returns the value of attribute hard_ttl.
-
#soft_ttl ⇒ Object
readonly
Returns the value of attribute soft_ttl.
Instance Method Summary collapse
- #hard_lock(id) ⇒ Object
- #initialize(options = {}) ⇒ Object
- #soft_lock(id) ⇒ Object
- #unlock(id) ⇒ Object
Instance Attribute Details
#hard_ttl ⇒ Object
Returns the value of attribute hard_ttl.
7 8 9 |
# File 'lib/circuitry/locks/base.rb', line 7 def hard_ttl @hard_ttl end |
#soft_ttl ⇒ Object
Returns the value of attribute soft_ttl.
7 8 9 |
# File 'lib/circuitry/locks/base.rb', line 7 def soft_ttl @soft_ttl end |
Instance Method Details
#hard_lock(id) ⇒ Object
18 19 20 |
# File 'lib/circuitry/locks/base.rb', line 18 def hard_lock(id) lock!(lock_key(id), hard_ttl) end |
#initialize(options = {}) ⇒ Object
9 10 11 12 |
# File 'lib/circuitry/locks/base.rb', line 9 def initialize( = {}) self.soft_ttl = .fetch(:soft_ttl, DEFAULT_SOFT_TTL) self.hard_ttl = .fetch(:hard_ttl, DEFAULT_HARD_TTL) end |
#soft_lock(id) ⇒ Object
14 15 16 |
# File 'lib/circuitry/locks/base.rb', line 14 def soft_lock(id) lock(lock_key(id), soft_ttl) end |
#unlock(id) ⇒ Object
22 23 24 |
# File 'lib/circuitry/locks/base.rb', line 22 def unlock(id) unlock!(lock_key(id)) end |