No commit activity in last 3 years
No release in over 3 years
Provides simple methods on an ActiveRecord model using an ActiveRecord concern to invalidate/save single_column caches.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

~> 4.0.0
 Project Readme

DatabaseCachedAttribute

Code Climate Build Status Gem Version

Description

Ruby gem that adds simple functions to invalidate single columns as a cache on an ActiveRecord models.

Using DatabaseCachedAttribute

DatabaseCachedAttribute is an ActiveSupport Concern and creates 1 set of helpers on inclusion and another on a different usage.

 gem install database_cached_attribute
class YourFunClass < ActiveRecord::Base
  include DatabaseCachedAttribute
  
  database_cached_attribute :your_column
end

That will create a few functions for your model such as:

your_obj = YourFunClass.new
your_obj.invalidate_your_column #invalidates and persists the change to the db if appropriate
your_obj.cache_your_column      #attempts to save your cache change to the db if appropriate
your_obj.only_your_column_changed? #tells you if your objects only change is that column

These helpers let you do nice things in your model like:

class YourFunClass < ActiveRecord::Base
  include DatabaseCachedAttribute
  database_cached_attribute :your_column

  has_many :other_things, before_add: :invalidate_your_column
end