Class | SynCache::CacheEntry |
In: |
lib/syncache/syncache.rb
|
Parent: | Object |
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 |
# 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
mark entry as dirty and schedule it to expire at given time
# 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
# File lib/syncache/syncache.rb, line 39 def record_access return if @dirty @expires = Time.now + (@ttl or FOREVER) end