Class: ActiveSupport::Cache::LibmemcachedStore::FetchWithRaceConditionTTLEntry

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, expires_in) ⇒ FetchWithRaceConditionTTLEntry

Returns a new instance of FetchWithRaceConditionTTLEntry.



33
34
35
36
# File 'lib/active_support/cache/libmemcached_store.rb', line 33

def initialize(value, expires_in)
  @value, @extended = value, false
  @expires_at = Time.now.to_i + expires_in
end

Instance Attribute Details

#extendedObject

Returns the value of attribute extended.



31
32
33
# File 'lib/active_support/cache/libmemcached_store.rb', line 31

def extended
  @extended
end

#valueObject

Returns the value of attribute value.



31
32
33
# File 'lib/active_support/cache/libmemcached_store.rb', line 31

def value
  @value
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/active_support/cache/libmemcached_store.rb', line 42

def expired?
  @expires_at <= Time.now.to_i
end

#expires_inObject



38
39
40
# File 'lib/active_support/cache/libmemcached_store.rb', line 38

def expires_in
  [@expires_at - Time.now.to_i, 1].max # never set to 0 -> never expires
end