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.
113 114 115 116 |
# File 'lib/optimizely/odp/lru_cache.rb', line 113 def initialize(value) @value = value @timestamp = Time.new end |
Instance Attribute Details
#timestamp ⇒ Object (readonly)
Individual element for the LRUCache.
111 112 113 |
# File 'lib/optimizely/odp/lru_cache.rb', line 111 def @timestamp end |
#value ⇒ Object (readonly)
Individual element for the LRUCache.
111 112 113 |
# File 'lib/optimizely/odp/lru_cache.rb', line 111 def value @value end |
Instance Method Details
#stale?(timeout) ⇒ Boolean
118 119 120 121 122 123 124 125 |
# File 'lib/optimizely/odp/lru_cache.rb', line 118 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 |