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, #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

Parameters:

Returns:



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