Module: VolatileCounterCache

Extended by:
ActiveSupport::Concern
Defined in:
lib/volatile_counter_cache.rb,
lib/volatile_counter_cache/version.rb

Overview

A model concern module to provide volatile counter cache logic to model class.

Examples:

class Tweet < ActiveRecord::Base
  include VolatileCounterCache
  has_many :favorites
  volatile_counter_cache :favorites, cache: Rails.cache
end
Tweet.first.favorites_count #=> 42
Tweet.first.favorites.first.destroy
Tweet.first.favorites_count #=> 41

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

CACHE_KEY_PREFIX =
'volatile-counter-cache'
VERSION =
"0.0.1"