Class: GemCP::Cache::Entry
- Inherits:
-
Data
- Object
- Data
- GemCP::Cache::Entry
- Defined in:
- lib/gemcp/cache.rb
Overview
A single cached response with freshness metadata.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#etag ⇒ Object
readonly
Returns the value of attribute etag.
-
#last_modified ⇒ Object
readonly
Returns the value of attribute last_modified.
-
#stored_at ⇒ Object
readonly
Returns the value of attribute stored_at.
Instance Method Summary collapse
-
#fresh?(ttl:, now: Time.now) ⇒ Boolean
Whether this entry is younger than ttl seconds.
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body
13 14 15 |
# File 'lib/gemcp/cache.rb', line 13 def body @body end |
#etag ⇒ Object (readonly)
Returns the value of attribute etag
13 14 15 |
# File 'lib/gemcp/cache.rb', line 13 def etag @etag end |
#last_modified ⇒ Object (readonly)
Returns the value of attribute last_modified
13 14 15 |
# File 'lib/gemcp/cache.rb', line 13 def last_modified @last_modified end |
#stored_at ⇒ Object (readonly)
Returns the value of attribute stored_at
13 14 15 |
# File 'lib/gemcp/cache.rb', line 13 def stored_at @stored_at end |
Instance Method Details
#fresh?(ttl:, now: Time.now) ⇒ Boolean
Returns whether this entry is younger than ttl seconds.
17 18 19 |
# File 'lib/gemcp/cache.rb', line 17 def fresh?(ttl:, now: Time.now) now.to_i - stored_at.to_i < ttl end |