Class: Fontist::Cache::Store::CacheEntry
- Inherits:
-
Object
- Object
- Fontist::Cache::Store::CacheEntry
- Defined in:
- lib/fontist/cache/store.rb
Overview
Cache entry with TTL support
Instance Attribute Summary collapse
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #expired? ⇒ Boolean
-
#initialize(value, ttl) ⇒ CacheEntry
constructor
A new instance of CacheEntry.
Constructor Details
#initialize(value, ttl) ⇒ CacheEntry
Returns a new instance of CacheEntry.
121 122 123 124 |
# File 'lib/fontist/cache/store.rb', line 121 def initialize(value, ttl) @value = value @expires_at = ttl ? (Time.now + ttl).to_i : nil end |
Instance Attribute Details
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
119 120 121 |
# File 'lib/fontist/cache/store.rb', line 119 def expires_at @expires_at end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
119 120 121 |
# File 'lib/fontist/cache/store.rb', line 119 def value @value end |
Instance Method Details
#expired? ⇒ Boolean
126 127 128 |
# File 'lib/fontist/cache/store.rb', line 126 def expired? !!(@expires_at && Time.now.to_i > @expires_at) end |