Class: WorkOS::Cache::Entry
- Inherits:
-
Object
- Object
- WorkOS::Cache::Entry
- Defined in:
- lib/workos/cache.rb
Overview
The Entry class represents a cache entry with a value and an expiration time
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
Checks if the entry has expired.
-
#initialize(value, expires_in_seconds) ⇒ Entry
constructor
Initializes a new cache entry.
Constructor Details
#initialize(value, expires_in_seconds) ⇒ Entry
Initializes a new cache entry
14 15 16 17 |
# File 'lib/workos/cache.rb', line 14 def initialize(value, expires_in_seconds) @value = value @expires_at = expires_in_seconds ? Time.now + expires_in_seconds : nil end |
Instance Attribute Details
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
9 10 11 |
# File 'lib/workos/cache.rb', line 9 def expires_at @expires_at end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
9 10 11 |
# File 'lib/workos/cache.rb', line 9 def value @value end |
Instance Method Details
#expired? ⇒ Boolean
Checks if the entry has expired
21 22 23 24 25 |
# File 'lib/workos/cache.rb', line 21 def expired? return false if expires_at.nil? Time.now > @expires_at end |