Class: FastExists::MultiTenant::Pool
- Inherits:
-
Object
- Object
- FastExists::MultiTenant::Pool
- Defined in:
- lib/fast_exists/multi_tenant/pool.rb
Instance Attribute Summary collapse
-
#backend ⇒ Object
readonly
Returns the value of attribute backend.
-
#expected_elements ⇒ Object
readonly
Returns the value of attribute expected_elements.
-
#false_positive_rate ⇒ Object
readonly
Returns the value of attribute false_positive_rate.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #add(tenant_id, attribute, value) ⇒ Object
- #clear ⇒ Object
- #contains?(tenant_id, attribute, value) ⇒ Boolean
-
#initialize(name:, expected_elements:, false_positive_rate: 0.001, backend_type: nil) ⇒ Pool
constructor
A new instance of Pool.
- #stats ⇒ Object
Constructor Details
#initialize(name:, expected_elements:, false_positive_rate: 0.001, backend_type: nil) ⇒ Pool
Returns a new instance of Pool.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/fast_exists/multi_tenant/pool.rb', line 8 def initialize(name:, expected_elements:, false_positive_rate: 0.001, backend_type: nil) @name = name @expected_elements = expected_elements @false_positive_rate = false_positive_rate @backend_type = backend_type || FastExists.configuration.backend @key = FastExists::MultiTenant::KeyLayout.pool_key(name) @backend = FastExists.backends.fetch( @backend_type, namespace: "pool:#{name}", expected_elements: expected_elements, false_positive_rate: false_positive_rate ) end |
Instance Attribute Details
#backend ⇒ Object (readonly)
Returns the value of attribute backend.
6 7 8 |
# File 'lib/fast_exists/multi_tenant/pool.rb', line 6 def backend @backend end |
#expected_elements ⇒ Object (readonly)
Returns the value of attribute expected_elements.
6 7 8 |
# File 'lib/fast_exists/multi_tenant/pool.rb', line 6 def expected_elements @expected_elements end |
#false_positive_rate ⇒ Object (readonly)
Returns the value of attribute false_positive_rate.
6 7 8 |
# File 'lib/fast_exists/multi_tenant/pool.rb', line 6 def false_positive_rate @false_positive_rate end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/fast_exists/multi_tenant/pool.rb', line 6 def name @name end |
Instance Method Details
#add(tenant_id, attribute, value) ⇒ Object
23 24 25 26 |
# File 'lib/fast_exists/multi_tenant/pool.rb', line 23 def add(tenant_id, attribute, value) composite_key = "#{tenant_id}:#{attribute}:#{value}" @backend.add(composite_key) end |
#clear ⇒ Object
33 34 35 |
# File 'lib/fast_exists/multi_tenant/pool.rb', line 33 def clear @backend.clear end |
#contains?(tenant_id, attribute, value) ⇒ Boolean
28 29 30 31 |
# File 'lib/fast_exists/multi_tenant/pool.rb', line 28 def contains?(tenant_id, attribute, value) composite_key = "#{tenant_id}:#{attribute}:#{value}" @backend.contains?(composite_key) end |
#stats ⇒ Object
37 38 39 |
# File 'lib/fast_exists/multi_tenant/pool.rb', line 37 def stats @backend.stats.merge(pool_name: @name, pool_key: @key) end |