Class: LockMethod::DefaultStorageClient::Entry
- Inherits:
-
Object
- Object
- LockMethod::DefaultStorageClient::Entry
- Defined in:
- lib/lock_method/default_storage_client.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#ttl ⇒ Object
readonly
Returns the value of attribute ttl.
-
#v ⇒ Object
readonly
Returns the value of attribute v.
Instance Method Summary collapse
- #expired? ⇒ Boolean
-
#initialize(v, ttl) ⇒ Entry
constructor
A new instance of Entry.
Constructor Details
#initialize(v, ttl) ⇒ Entry
Returns a new instance of Entry.
11 12 13 14 15 |
# File 'lib/lock_method/default_storage_client.rb', line 11 def initialize(v, ttl) @created_at = ::Time.now @ttl = ttl.to_f @v = v end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
8 9 10 |
# File 'lib/lock_method/default_storage_client.rb', line 8 def created_at @created_at end |
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl.
9 10 11 |
# File 'lib/lock_method/default_storage_client.rb', line 9 def ttl @ttl end |
#v ⇒ Object (readonly)
Returns the value of attribute v.
10 11 12 |
# File 'lib/lock_method/default_storage_client.rb', line 10 def v @v end |
Instance Method Details
#expired? ⇒ Boolean
16 17 18 |
# File 'lib/lock_method/default_storage_client.rb', line 16 def expired? ttl > 0 and (::Time.now - created_at) > ttl end |