Inlining locked?
Since `locked?` and `arel_from_relation` overlaps, so just do `arel_from_relation` first and inline `locked?`.
This commit is contained in:
parent
0aa832e590
commit
b453bff351
@ -94,8 +94,11 @@ def clear_query_cache
|
||||
end
|
||||
|
||||
def select_all(arel, name = nil, binds = [], preparable: nil)
|
||||
if @query_cache_enabled && !locked?(arel)
|
||||
arel = arel_from_relation(arel)
|
||||
arel = arel_from_relation(arel)
|
||||
|
||||
# If arel is locked this is a SELECT ... FOR UPDATE or somesuch.
|
||||
# Such queries should not be cached.
|
||||
if @query_cache_enabled && !(arel.respond_to?(:locked) && arel.locked)
|
||||
sql, binds, preparable = to_sql_and_binds(arel, binds, preparable)
|
||||
|
||||
cache_sql(sql, name, binds) { super(sql, name, binds, preparable: preparable) }
|
||||
@ -134,13 +137,6 @@ def cache_notification_info(sql, name, binds)
|
||||
}
|
||||
end
|
||||
|
||||
# If arel is locked this is a SELECT ... FOR UPDATE or somesuch. Such
|
||||
# queries should not be cached.
|
||||
def locked?(arel)
|
||||
arel = arel.arel if arel.is_a?(Relation)
|
||||
arel.respond_to?(:locked) && arel.locked
|
||||
end
|
||||
|
||||
def configure_query_cache!
|
||||
enable_query_cache! if pool.query_cache_enabled
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user