Class: Wayfarer::Frontiers::MemoryBloomfilter Private

Inherits:
MemoryFrontier show all
Defined in:
lib/wayfarer/frontiers/memory_bloomfilter.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

An in-memory bloomfilter.

Direct Known Subclasses

RedisBloomfilter

Instance Attribute Summary

Attributes inherited from Frontier

#config

Instance Method Summary collapse

Methods inherited from MemoryFrontier

#current_uris, #stage, #staged?, #staged_uris

Methods inherited from Frontier

#current_uris, #cycle, #filter_staged_uris!, #reset_staged_uris!, #stage, #staged?, #staged_uris, #swap!

Constructor Details

#initialize(config) ⇒ MemoryBloomfilter

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of MemoryBloomfilter.



10
11
12
13
# File 'lib/wayfarer/frontiers/memory_bloomfilter.rb', line 10

def initialize(config)
  @filter = BloomFilter::Native.new(config.bloomfilter_opts)
  super(config)
end

Instance Method Details

#cache(*uris) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
# File 'lib/wayfarer/frontiers/memory_bloomfilter.rb', line 16

def cache(*uris)
  uris.each { |uri| @filter.insert(uri) }
end

#cached?(uri) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


21
22
23
# File 'lib/wayfarer/frontiers/memory_bloomfilter.rb', line 21

def cached?(uri)
  @filter.include?(uri)
end

#freeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Frees up memory.



26
27
28
29
# File 'lib/wayfarer/frontiers/memory_bloomfilter.rb', line 26

def free
  @filter.clear
  super
end