13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/second_level_cache/active_record/has_one_association.rb', line 13
def find_target_with_second_level_cache
return find_target_without_second_level_cache unless klass.second_level_cache_enabled?
cache_record = klass.fetch_by_uniq_key(owner[reflection.active_record_primary_key], reflection.foreign_key)
return cache_record.tap{|record| set_inverse_instance(record)} if cache_record
record = find_target_without_second_level_cache
record.tap do |r|
set_inverse_instance(r)
r.write_second_level_cache
end if record
end
|