Class: Arachni::Support::Cache::RandomReplacement

Inherits:
Base
  • Object
show all
Defined in:
lib/arachni/support/cache/random_replacement.rb

Overview

Random Replacement cache implementation.

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?, #delete, #dup, #empty?, #fetch_or_store, #hash, #include?, #size, #uncap, #uncapped?

Constructor Details

#initializeRandomReplacement

Returns a new instance of RandomReplacement.

See Also:

  • Cache::Base#initialize


20
21
22
23
# File 'lib/arachni/support/cache/random_replacement.rb', line 20

def initialize( * )
    super
    @keys = []
end

Instance Method Details

#clearObject



34
35
36
37
# File 'lib/arachni/support/cache/random_replacement.rb', line 34

def clear
    super
    @keys.clear
end

#store(k, v) ⇒ Object

See Also:

  • Cache::Base#store


26
27
28
29
30
31
32
# File 'lib/arachni/support/cache/random_replacement.rb', line 26

def store( k, v )
    already_in = include?( k )

    super( k, v )
ensure
    @keys << k if !already_in
end