Class: MODL::Parser::ObjectCache::CacheEntry

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#objectObject (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

Returns:

  • (Boolean)


43
44
45
# File 'lib/modl/parser/object_cache.rb', line 43

def expired?
  @expiry_time < Time.now
end