Class: FastExists::MultiTenant::Strategies::GlobalStrategy
- Inherits:
-
BaseStrategy
- Object
- BaseStrategy
- FastExists::MultiTenant::Strategies::GlobalStrategy
- Defined in:
- lib/fast_exists/multi_tenant/strategies/global_strategy.rb
Instance Attribute Summary
Attributes inherited from BaseStrategy
Instance Method Summary collapse
- #add(tenant_id, attribute, value) ⇒ Object
- #classify_tenant(_tenant_id, _record_count) ⇒ Object
- #contains?(tenant_id, attribute, value) ⇒ Boolean
-
#initialize(options = {}) ⇒ GlobalStrategy
constructor
A new instance of GlobalStrategy.
- #stats ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ GlobalStrategy
Returns a new instance of GlobalStrategy.
7 8 9 10 11 12 13 14 15 |
# File 'lib/fast_exists/multi_tenant/strategies/global_strategy.rb', line 7 def initialize( = {}) super @backend = FastExists.backends.fetch( FastExists.configuration.backend, namespace: "global", expected_elements: [:expected_elements] || FastExists.configuration.expected_elements, false_positive_rate: [:false_positive_rate] || FastExists.configuration.false_positive_rate ) end |
Instance Method Details
#add(tenant_id, attribute, value) ⇒ Object
17 18 19 20 |
# File 'lib/fast_exists/multi_tenant/strategies/global_strategy.rb', line 17 def add(tenant_id, attribute, value) composite_key = "#{tenant_id}:#{attribute}:#{value}" @backend.add(composite_key) end |
#classify_tenant(_tenant_id, _record_count) ⇒ Object
27 28 29 |
# File 'lib/fast_exists/multi_tenant/strategies/global_strategy.rb', line 27 def classify_tenant(_tenant_id, _record_count) :global end |
#contains?(tenant_id, attribute, value) ⇒ Boolean
22 23 24 25 |
# File 'lib/fast_exists/multi_tenant/strategies/global_strategy.rb', line 22 def contains?(tenant_id, attribute, value) composite_key = "#{tenant_id}:#{attribute}:#{value}" @backend.contains?(composite_key) end |
#stats ⇒ Object
31 32 33 |
# File 'lib/fast_exists/multi_tenant/strategies/global_strategy.rb', line 31 def stats @backend.stats.merge(strategy: :global, key: FastExists::MultiTenant::KeyLayout.global_key) end |