Class: T1000::Lock
- Inherits:
-
Struct
- Object
- Struct
- T1000::Lock
- Defined in:
- lib/t-1000/lock.rb
Instance Attribute Summary collapse
-
#ip ⇒ Object
Returns the value of attribute ip.
Instance Method Summary collapse
Instance Attribute Details
#ip ⇒ Object
Returns the value of attribute ip
2 3 4 |
# File 'lib/t-1000/lock.rb', line 2 def ip @ip end |
Instance Method Details
#key ⇒ Object
4 5 6 |
# File 'lib/t-1000/lock.rb', line 4 def key @key ||= ActiveSupport::Cache. [ip], :ip_lock end |
#lock!(time = 1.minute) ⇒ Object
8 9 10 |
# File 'lib/t-1000/lock.rb', line 8 def lock!(time = 1.minute) T1000.cache.store.write(key, true, expires_in: time) end |
#locked? ⇒ Boolean
12 13 14 |
# File 'lib/t-1000/lock.rb', line 12 def locked? !!T1000.cache.store.read(key) end |