Sha256: f55a44bd06ac3470756005c8a116a6ecdf7748ec0284d59520e69d7740bba866
Contents?: true
Size: 880 Bytes
Versions: 1
Compression:
Stored size: 880 Bytes
Contents
# -*- encoding : utf-8 -*- module SecondLevelCache module ActiveRecord module Associations module BelongsToAssociation extend ActiveSupport::Concern included do class_eval do alias_method_chain :find_target, :second_level_cache end end def find_target_with_second_level_cache return find_target_without_second_level_cache unless klass.second_level_cache_enabled? cache_record = klass.read_second_level_cache(second_level_cache_key) return cache_record.tap{|record| set_inverse_instance(record)} if cache_record record = find_target_without_second_level_cache record.write_second_level_cache record end private def second_level_cache_key owner[reflection.foreign_key] end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
second_level_cache-1.3.2 | lib/second_level_cache/active_record/belongs_to_association.rb |