Module: SecondLevelCache::ActiveRecord::Associations::BelongsToAssociation
- Defined in:
- lib/second_level_cache/active_record/belongs_to_association.rb
Instance Method Summary collapse
Instance Method Details
#find_target ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/second_level_cache/active_record/belongs_to_association.rb', line 7 def find_target return super unless klass.second_level_cache_enabled? cache_record = klass.read_second_level_cache(second_level_cache_key) if cache_record return cache_record.tap { |record| set_inverse_instance(record) } end record = super return nil unless record record.tap do |r| set_inverse_instance(r) r.write_second_level_cache end end |