Class: LockMethod::DefaultStorageClient::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/lock_method/default_storage_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_atObject (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

#ttlObject (readonly)

Returns the value of attribute ttl.



9
10
11
# File 'lib/lock_method/default_storage_client.rb', line 9

def ttl
  @ttl
end

#vObject (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

Returns:

  • (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