Module: RecordCache::ActiveRecord::UpdateAll::InstanceMethods
- Defined in:
- lib/record_cache/datastore/active_record_30.rb,
lib/record_cache/datastore/active_record_31.rb
Instance Method Summary collapse
Instance Method Details
#update_all_with_record_cache(updates, conditions = nil, options = {}) ⇒ Object
270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/record_cache/datastore/active_record_30.rb', line 270 def update_all_with_record_cache(updates, conditions = nil, = {}) result = update_all_without_record_cache(updates, conditions, ) if record_cache? # when this condition is met, the arel.update method will be called on the current scope, see ActiveRecord::Relation#update_all unless conditions || .present? || @limit_value.present? != @order_values.present? # go straight to SQL result (without instantiating records) for optimal performance connection.execute(select('id').to_sql).each{ |row| record_cache.invalidate(:id, (row.is_a?(Hash) ? row['id'] : row.first).to_i ) } end end result end |