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.
111 112 113 114 |
# File 'lib/fontist/cache/store.rb', line 111 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.
109 110 111 |
# File 'lib/fontist/cache/store.rb', line 109 def expires_at @expires_at end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
109 110 111 |
# File 'lib/fontist/cache/store.rb', line 109 def value @value end |
Instance Method Details
#expired? ⇒ Boolean
116 117 118 |
# File 'lib/fontist/cache/store.rb', line 116 def expired? !!(@expires_at && Time.now.to_i > @expires_at) end |