Class: Redis::BloomfilterDriver::RubyTest
- Inherits:
-
Object
- Object
- Redis::BloomfilterDriver::RubyTest
- Defined in:
- lib/bloomfilter_driver/ruby_test.rb
Overview
It uses different hash strategy Usefule for benchmarking
Instance Attribute Summary collapse
-
#redis ⇒ Object
Returns the value of attribute redis.
Instance Method Summary collapse
-
#clear ⇒ Object
It deletes a bloomfilter.
-
#include?(key) ⇒ Boolean
It checks if a key is part of the set.
-
#initialize(options = {}) ⇒ RubyTest
constructor
A new instance of RubyTest.
-
#insert(data) ⇒ Object
Insert a new element.
-
#remove(data) ⇒ Object
Insert a new element.
Constructor Details
#initialize(options = {}) ⇒ RubyTest
Returns a new instance of RubyTest.
11 12 13 |
# File 'lib/bloomfilter_driver/ruby_test.rb', line 11 def initialize( = {}) @options = end |
Instance Attribute Details
#redis ⇒ Object
Returns the value of attribute redis.
9 10 11 |
# File 'lib/bloomfilter_driver/ruby_test.rb', line 9 def redis @redis end |
Instance Method Details
#clear ⇒ Object
It deletes a bloomfilter
40 41 42 |
# File 'lib/bloomfilter_driver/ruby_test.rb', line 40 def clear @redis.del @options[:key_name] end |
#include?(key) ⇒ Boolean
It checks if a key is part of the set
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bloomfilter_driver/ruby_test.rb', line 26 def include?(key) indexes = [] indexes_for(key) { |idx| indexes << idx } return false if @redis.getbit(@options[:key_name], indexes.shift) == 0 result = @redis.pipelined do indexes.each {|idx| @redis.getbit(@options[:key_name], idx)} end !result.include?(0) end |
#insert(data) ⇒ Object
Insert a new element
16 17 18 |
# File 'lib/bloomfilter_driver/ruby_test.rb', line 16 def insert(data) set data, 1 end |
#remove(data) ⇒ Object
Insert a new element
21 22 23 |
# File 'lib/bloomfilter_driver/ruby_test.rb', line 21 def remove(data) set data, 0 end |