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)
36 37 38 39 40 |
# File 'lib/modl/parser/object_cache.rb', line 36 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.
33 34 35 |
# File 'lib/modl/parser/object_cache.rb', line 33 def object @object end |
Instance Method Details
#expired? ⇒ Boolean
Check whether the CacheEntry is live
43 44 45 |
# File 'lib/modl/parser/object_cache.rb', line 43 def expired? @expiry_time < Time.now end |