Class: Schematic::LocalCache::CacheEntry
- Inherits:
-
Object
- Object
- Schematic::LocalCache::CacheEntry
- Defined in:
- lib/schematic/cache.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#ttl ⇒ Object
readonly
Returns the value of attribute ttl.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #expired? ⇒ Boolean
-
#initialize(value, ttl) ⇒ CacheEntry
constructor
A new instance of CacheEntry.
Constructor Details
#initialize(value, ttl) ⇒ CacheEntry
Returns a new instance of CacheEntry.
125 126 127 128 129 |
# File 'lib/schematic/cache.rb', line 125 def initialize(value, ttl) @value = value @ttl = ttl @created_at = Process.clock_gettime(Process::CLOCK_MONOTONIC) end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
123 124 125 |
# File 'lib/schematic/cache.rb', line 123 def created_at @created_at end |
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl.
123 124 125 |
# File 'lib/schematic/cache.rb', line 123 def ttl @ttl end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
123 124 125 |
# File 'lib/schematic/cache.rb', line 123 def value @value end |
Instance Method Details
#expired? ⇒ Boolean
131 132 133 |
# File 'lib/schematic/cache.rb', line 131 def expired? Process.clock_gettime(Process::CLOCK_MONOTONIC) - created_at > ttl end |