Class: Arachni::Support::LookUp::Moolb

Inherits:
Base show all
Defined in:
lib/arachni/support/lookup/moolb.rb

Overview

Opposite of Bloom a filter, ergo Moolb.

Basically a cache used for look-up operations.

Author:

Constant Summary collapse

DEFAULT_OPTIONS =
{
    strategy:   Support::Cache::RandomReplacement,
    max_size:   100_000
}

Instance Attribute Summary

Attributes inherited from Base

#collection

Instance Method Summary collapse

Methods inherited from Base

#==, #any?, #clear, #delete, #dup, #empty?, #hash, #include?, #size

Constructor Details

#initialize(options = {}) ⇒ Moolb

Returns a new instance of Moolb.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :strategy (Support::Cache::Base) — default: Support::Cache::RandomReplacement

    Sets the type of cache to use.

  • :max_size (Integer) — default: 100_000

    Maximum size of the cache.

See Also:



34
35
36
37
38
39
# File 'lib/arachni/support/lookup/moolb.rb', line 34

def initialize( options = {} )
    super( options )

    @options.merge!( DEFAULT_OPTIONS.merge( options ) )
    @collection = @options[:strategy].new( @options[:max_size] )
end

Instance Method Details

#<<(item) ⇒ HashSet Also known as: add

Returns self.

Parameters:

  • item (#persistent_hash)

    Item to insert.

Returns:



46
47
48
49
# File 'lib/arachni/support/lookup/moolb.rb', line 46

def <<( item )
    @collection[calculate_hash( item )] = true
    self
end