Class: ActiveRecord::ConnectionAdapters::MysqlAdapter

Inherits:
AbstractAdapter show all
Defined in:
lib/query_memcached.rb

Instance Attribute Summary

Attributes inherited from AbstractAdapter

#memcache_query_cache_options

Instance Method Summary collapse

Instance Method Details

#execute_with_clean_query_cache(*args) ⇒ Object

alias_method_chain for expiring cache if necessary



76
77
78
79
80
81
82
83
84
85
# File 'lib/query_memcached.rb', line 76

def execute_with_clean_query_cache(*args)
  return execute_without_clean_query_cache(*args) unless self.memcache_query_cache_options && query_cache_enabled
  sql = args[0].strip
  if sql =~ /^(INSERT|UPDATE|ALTER|DROP|DELETE)/i
    # can only modify one table at a time...so stop after matching the first table name
    table_name = ActiveRecord::Base.extract_table_names(sql).first
    ActiveRecord::Base.increase_version!(table_name)
  end
  execute_without_clean_query_cache(*args)
end