Module: Moribus::AggregatedCacheBehavior

Extended by:
ActiveSupport::Concern
Defined in:
lib/moribus/aggregated_cache_behavior.rb

Overview

This module provides additional in-memory caching for model that behaves in aggregated way. For that reason, :aggregated_records_cache hash class instance variable is added, and the @aggregated_caching_column class instance variable should be defined by class. The value of corresponding attribute of the model is used as a cache key.

The original lookup_self method is overloaded to lookup in cache first. If this lookup fails, native aggregated routines are performed and resulting record is added to the cache.

Please note that this module is not to be included manually. Use class-level acts_as_aggregated instead, supplied with an :cache_by option:

class EmailDomain < ActiveRecord::Base
  acts_as_aggregated :cache_by => :domain
  # .. rest of definition
end

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

NotAggregatedError =

Raised when trying to include the module to a non-aggregated model.

Class.new(::ArgumentError)