Class: Arachni::Support::Cache::Preference

Inherits:
Base show all
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.

Author:

Instance Attribute Summary

Attributes inherited from Base

#max_size

Instance Method Summary collapse

Methods inherited from Base

#[], #[]=, #any?, #capped?, #clear, #delete, #empty?, #fetch_or_store, #include?, #initialize, #size, #uncap, #uncapped?

Constructor Details

This class inherits a constructor from Arachni::Support::Cache::Base

Instance Method Details

#prefer(&block) ⇒ Object



43
44
45
# File 'lib/arachni/support/cache/preference.rb', line 43

def prefer( &block )
    @preference = block
end

#store(k, v) ⇒ Object

Storage method

Parameters:

Returns:



38
39
40
41
# File 'lib/arachni/support/cache/preference.rb', line 38

def store( k, v )
    prune if capped? && (size > max_size - 1)
    cache[k.hash] = v
end