method

compute_if_absent

rails latest stable - Class: ActiveRecord::ConnectionAdapters::QueryCache::Store

Method not available on this version

This method is only available on newer versions. The first available version (v7.2.3) is shown here.

compute_if_absent(key)
public

No documentation available.

# File activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb, line 67
        def compute_if_absent(key)
          check_version

          return yield unless @enabled

          if entry = @map.delete(key)
            return @map[key] = entry
          end

          if @max_size && @map.size >= @max_size
            @map.shift # evict the oldest entry
          end

          @map[key] ||= yield
        end