Class: FastExists::Backends::Base
- Inherits:
-
Object
- Object
- FastExists::Backends::Base
show all
- Defined in:
- lib/fast_exists/backends/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
8
9
10
11
12
|
# File 'lib/fast_exists/backends/base.rb', line 8
def initialize(options = {})
@options = options
@expected_elements = options[:expected_elements] || FastExists.configuration.expected_elements
@false_positive_rate = options[:false_positive_rate] || FastExists.configuration.false_positive_rate
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
6
7
8
|
# File 'lib/fast_exists/backends/base.rb', line 6
def options
@options
end
|
Instance Method Details
#add(key) ⇒ Object
14
15
16
|
# File 'lib/fast_exists/backends/base.rb', line 14
def add(key)
raise NotImplementedError, "#{self.class.name}#add is not implemented"
end
|
#capacity ⇒ Object
38
39
40
|
# File 'lib/fast_exists/backends/base.rb', line 38
def capacity
@expected_elements
end
|
#clear ⇒ Object
22
23
24
|
# File 'lib/fast_exists/backends/base.rb', line 22
def clear
raise NotImplementedError, "#{self.class.name}#clear is not implemented"
end
|
#contains?(key) ⇒ Boolean
18
19
20
|
# File 'lib/fast_exists/backends/base.rb', line 18
def contains?(key)
raise NotImplementedError, "#{self.class.name}#contains? is not implemented"
end
|
#count ⇒ Object
34
35
36
|
# File 'lib/fast_exists/backends/base.rb', line 34
def count
0
end
|
#load ⇒ Object
30
31
32
|
# File 'lib/fast_exists/backends/base.rb', line 30
def load
true
end
|
#rebuild(enumerable) ⇒ Object
50
51
52
53
54
55
56
57
|
# File 'lib/fast_exists/backends/base.rb', line 50
def rebuild(enumerable)
clear
enumerable.each do |item|
add(item)
end
save
true
end
|
#save ⇒ Object
26
27
28
|
# File 'lib/fast_exists/backends/base.rb', line 26
def save
true
end
|
#stats ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/fast_exists/backends/base.rb', line 42
def stats
{
backend: self.class.name,
capacity: capacity,
count: count
}
end
|