Class SynCache::CacheEntry
In: lib/syncache/syncache.rb
Parent: Object

Methods

Attributes

sync  [R]  use this to synchronize access to value
ttl  [RW]  change this to make the entry expire sooner
value  [RW]  stores the value object

Public Class methods

[Source]

# File lib/syncache/syncache.rb, line 19
  def initialize(ttl = nil, value = nil)
    @value = value
    @ttl = ttl
    @dirty = false
    record_access

    @sync = Mutex.new
  end

Public Instance methods

mark entry as dirty and schedule it to expire at given time

[Source]

# File lib/syncache/syncache.rb, line 58
  def expire_at(time)
    @expires = time if @expires > time
    @dirty = true
  end

record the fact that the entry was accessed

[Source]

# File lib/syncache/syncache.rb, line 39
  def record_access
    return if @dirty
    @expires = Time.now + (@ttl or FOREVER)
  end

entries with lowest index will be replaced first

[Source]

# File lib/syncache/syncache.rb, line 46
  def replacement_index
    @expires
  end

check if entry is stale

[Source]

# File lib/syncache/syncache.rb, line 52
  def stale?
    @expires < Time.now
  end

[Validate]