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.
Constructor Details
#initialize(options = {}) ⇒ RubyTest
Returns a new instance of RubyTest.
13 14 15 |
# File 'lib/bloomfilter_driver/ruby_test.rb', line 13 def initialize( = {}) @options = end |
Instance Attribute Details
#redis ⇒ Object
Returns the value of attribute redis.
11 12 13 |
# File 'lib/bloomfilter_driver/ruby_test.rb', line 11 def redis @redis end |
Instance Method Details
#clear ⇒ Object
It deletes a bloomfilter
37 38 39 |
# File 'lib/bloomfilter_driver/ruby_test.rb', line 37 def clear @redis.del @options[:key_name] end |
#include?(key) ⇒ Boolean
It checks if a key is part of the set
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/bloomfilter_driver/ruby_test.rb', line 23 def include?(key) indexes = [] indexes_for(key) { |idx| indexes << idx } return false if @redis.getbit(@options[:key_name], indexes.shift).zero? 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
18 19 20 |
# File 'lib/bloomfilter_driver/ruby_test.rb', line 18 def insert(data) set data, 1 end |