Sha256: 2159afb7047797f621f42494003beaaecdd5fe33fe1b9ff7d13b66867364528b

Contents?: true

Size: 1.36 KB

Versions: 7

Compression:

Stored size: 1.36 KB

Contents

=begin
    Copyright 2010-2014 Tasos Laskos <tasos.laskos@arachni-scanner.com>

    This file is part of the Arachni Framework project and is subject to
    redistribution and commercial restrictions. Please see the Arachni Framework
    web site for more information on licensing and terms of use.
=end

require_relative '../cache'

module Arachni
module Support::LookUp

# Opposite of Bloom a filter, ergo Moolb.
#
# Basically a cache used for look-up operations.
#
# @author Tasos "Zapotek" Laskos <tasos.laskos@arachni-scanner.com>
class Moolb < Base

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

    # @param    [Hash]  options
    # @option options [Support::Cache::Base]  :strategy (Support::Cache::RandomReplacement)
    #   Sets the type of cache to use.
    #
    # @option options [Integer]  :max_size (100_000)
    #   Maximum size of the cache.
    #
    # @see DEFAULT_OPTIONS
    def initialize( options = {} )
        super( options )

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

    # @param    [#persistent_hash] item
    #   Item to insert.
    #
    # @return   [HashSet]
    #   `self`
    def <<( item )
        @collection[calculate_hash( item )] = true
        self
    end
    alias :add :<<

end

end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
arachni-1.0.6 lib/arachni/support/lookup/moolb.rb
arachni-1.0.5 lib/arachni/support/lookup/moolb.rb
arachni-1.0.4 lib/arachni/support/lookup/moolb.rb
arachni-1.0.3 lib/arachni/support/lookup/moolb.rb
arachni-1.0.2 lib/arachni/support/lookup/moolb.rb
arachni-1.0.1 lib/arachni/support/lookup/moolb.rb
arachni-1.0 lib/arachni/support/lookup/moolb.rb