命名空间
方法
- C
- D
- E
- N
- U
属性
[R] | query_cache | |
[R] | query_cache_enabled |
类公共方法
dirties_query_cache(base, *method_names) 链接
# File activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb, line 20 def dirties_query_cache(base, *method_names) method_names.each do |method_name| base.class_eval <<-end_code, __FILE__, __LINE__ + 1 def #{method_name}(...) ActiveRecord::Base.clear_query_caches_for_current_thread super end end_code end end
new(*) 链接
实例公共方法
cache() 链接
在块内启用查询缓存。
clear_query_cache() 链接
清除查询缓存。
显式调用此方法的一个原因是在要求数据库随机化结果的查询之间。否则,缓存会看到相同的 SQL 查询,并每次重复返回相同的结果,从而悄无声息地破坏你所期望的随机性。
disable_query_cache!() 链接
enable_query_cache!() 链接
来源:显示 | 在 GitHub 上
# File activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb, line 71 def enable_query_cache! @query_cache_enabled = true end
uncached() 链接
在块内禁用查询缓存。
来源:显示 | 在 GitHub 上
# File activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb, line 81 def uncached old, @query_cache_enabled = @query_cache_enabled, false yield ensure @query_cache_enabled = old end