Class: Arachni::Support::Cache::Preference
- Defined in:
- lib/arachni/support/cache/preference.rb
Overview
Random Replacement cache implementation.
Better suited for low-latency operations, discards entries at random in order to make room for new ones.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #prefer(&block) ⇒ Object
-
#store(k, v) ⇒ Object
Storage method.
Methods inherited from Base
#==, #[], #[]=, #any?, #capped?, #clear, #delete, #dup, #empty?, #fetch_or_store, #hash, #include?, #initialize, #size, #uncap, #uncapped?
Constructor Details
This class inherits a constructor from Arachni::Support::Cache::Base
Instance Method Details
#prefer(&block) ⇒ Object
34 35 36 |
# File 'lib/arachni/support/cache/preference.rb', line 34 def prefer( &block ) @preference = block end |
#store(k, v) ⇒ Object
Storage method
29 30 31 32 |
# File 'lib/arachni/support/cache/preference.rb', line 29 def store( k, v ) prune if capped? && (size > max_size - 1) cache[make_key( k )] = v end |