Class: MODL::Parser::ObjectCache::CacheEntry
- Inherits:
-
Object
- Object
- MODL::Parser::ObjectCache::CacheEntry
- Defined in:
- lib/modl/parser/object_cache.rb
Overview
A cache record to keep track of the time since an object was last cached.
Constant Summary collapse
- TTL_ONE_HOUR =
seconds
3_600
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
-
#expired? ⇒ Boolean
Check whether the CacheEntry is live.
-
#initialize(object, ttl = nil) ⇒ CacheEntry
constructor
Initialiase the CacheEntry with an object and an optional ttl in seconds (default 1 hour).
Constructor Details
#initialize(object, ttl = nil) ⇒ CacheEntry
Initialiase the CacheEntry with an object and an optional ttl in seconds (default 1 hour)
13 14 15 16 17 |
# File 'lib/modl/parser/object_cache.rb', line 13 def initialize(object, ttl = nil) ttl = TTL_ONE_HOUR if ttl.nil? @object = object @expiry_time = Time.now + ttl end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
10 11 12 |
# File 'lib/modl/parser/object_cache.rb', line 10 def object @object end |
Instance Method Details
#expired? ⇒ Boolean
Check whether the CacheEntry is live
20 21 22 |
# File 'lib/modl/parser/object_cache.rb', line 20 def expired? @expiry_time < Time.now end |