Class: Ukiryu::Cache::Entry Private
- Inherits:
-
Object
- Object
- Ukiryu::Cache::Entry
- Defined in:
- lib/ukiryu/cache.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Cache entry with expiration tracking
Instance Attribute Summary collapse
- #accessed_at ⇒ Object readonly private
- #created_at ⇒ Object readonly private
- #value ⇒ Object readonly private
Instance Method Summary collapse
- #expired?(ttl) ⇒ Boolean private
-
#initialize(value) ⇒ Entry
constructor
private
A new instance of Entry.
- #touch! ⇒ Object private
Constructor Details
#initialize(value) ⇒ Entry
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Entry.
23 24 25 26 27 |
# File 'lib/ukiryu/cache.rb', line 23 def initialize(value) @value = value @created_at = Time.now @accessed_at = @created_at end |
Instance Attribute Details
#accessed_at ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 |
# File 'lib/ukiryu/cache.rb', line 21 def accessed_at @accessed_at end |
#created_at ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 |
# File 'lib/ukiryu/cache.rb', line 21 def created_at @created_at end |
#value ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 |
# File 'lib/ukiryu/cache.rb', line 21 def value @value end |
Instance Method Details
#expired?(ttl) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 36 37 |
# File 'lib/ukiryu/cache.rb', line 33 def expired?(ttl) return false unless ttl (Time.now - @created_at) > ttl end |
#touch! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 |
# File 'lib/ukiryu/cache.rb', line 29 def touch! @accessed_at = Time.now end |