Class: SolidCache::Record
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SolidCache::Record
- Defined in:
- app/models/solid_cache/record.rb
Direct Known Subclasses
Constant Summary collapse
- NULL_INSTRUMENTER =
ActiveSupport::Notifications::Instrumenter.new(ActiveSupport::Notifications::Fanout.new)
Class Method Summary collapse
- .disable_instrumentation(&block) ⇒ Object
- .each_shard(&block) ⇒ Object
- .with_shard(shard, &block) ⇒ Object
Class Method Details
.disable_instrumentation(&block) ⇒ Object
12 13 14 |
# File 'app/models/solid_cache/record.rb', line 12 def disable_instrumentation(&block) connection.with_instrumenter(NULL_INSTRUMENTER, &block) end |
.each_shard(&block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/models/solid_cache/record.rb', line 24 def each_shard(&block) return to_enum(:each_shard) unless block_given? if SolidCache.configuration.sharded? SolidCache.configuration.shard_keys.each do |shard| Record.with_shard(shard, &block) end else yield end end |
.with_shard(shard, &block) ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/models/solid_cache/record.rb', line 16 def with_shard(shard, &block) if shard && SolidCache.configuration.sharded? connected_to(shard: shard, role: default_role, prevent_writes: false, &block) else block.call end end |