Class: Schematic::LocalCache::CacheEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/schematic/cache.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

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_atObject (readonly)

Returns the value of attribute created_at.



123
124
125
# File 'lib/schematic/cache.rb', line 123

def created_at
  @created_at
end

#ttlObject (readonly)

Returns the value of attribute ttl.



123
124
125
# File 'lib/schematic/cache.rb', line 123

def ttl
  @ttl
end

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

Returns:

  • (Boolean)


131
132
133
# File 'lib/schematic/cache.rb', line 131

def expired?
  Process.clock_gettime(Process::CLOCK_MONOTONIC) - created_at > ttl
end