Module: Philiprehberger::CacheKit::Callbacks

Included in:
Store
Defined in:
lib/philiprehberger/cache_kit/callbacks.rb

Overview

Eviction callback support for Store.

Instance Method Summary collapse

Instance Method Details

#on_evict {|key, value| ... } ⇒ void

This method returns an undefined value.

Register a callback invoked when entries are evicted.

Yields:

  • (key, value)

    called on eviction (LRU or TTL expiry)



11
12
13
# File 'lib/philiprehberger/cache_kit/callbacks.rb', line 11

def on_evict(&block)
  @mutex.synchronize { @evict_callbacks << block }
end