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.



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

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.



27
28
29
# File 'lib/active_support/cache/libmemcached_store.rb', line 27

def extended
  @extended
end

#valueObject

Returns the value of attribute value.



27
28
29
# File 'lib/active_support/cache/libmemcached_store.rb', line 27

def value
  @value
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


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

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

#expires_inObject



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

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