Class: Optimizely::CacheElement
- Inherits:
-
Object
- Object
- Optimizely::CacheElement
- Defined in:
- lib/optimizely/odp/lru_cache.rb
Instance Attribute Summary collapse
-
#timestamp ⇒ Object
readonly
Individual element for the LRUCache.
-
#value ⇒ Object
readonly
Individual element for the LRUCache.
Instance Method Summary collapse
-
#initialize(value) ⇒ CacheElement
constructor
A new instance of CacheElement.
- #stale?(timeout) ⇒ Boolean
Constructor Details
#initialize(value) ⇒ CacheElement
Returns a new instance of CacheElement.
100 101 102 103 |
# File 'lib/optimizely/odp/lru_cache.rb', line 100 def initialize(value) @value = value @timestamp = Time.new end |
Instance Attribute Details
#timestamp ⇒ Object (readonly)
Individual element for the LRUCache.
98 99 100 |
# File 'lib/optimizely/odp/lru_cache.rb', line 98 def @timestamp end |
#value ⇒ Object (readonly)
Individual element for the LRUCache.
98 99 100 |
# File 'lib/optimizely/odp/lru_cache.rb', line 98 def value @value end |
Instance Method Details
#stale?(timeout) ⇒ Boolean
105 106 107 108 109 110 111 112 |
# File 'lib/optimizely/odp/lru_cache.rb', line 105 def stale?(timeout) # Returns true if the provided timeout has passed since the element's timestamp. # # @param timeout - The duration to check against return false if timeout <= 0 Time.new - @timestamp >= timeout end |