0.0
No commit activity in last 3 years
No release in over 3 years
It makes cache expiration in rails much simpler
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 3.1.0
>= 3.1.0
>= 3.1.0
>= 2.2.0
 Project Readme

Note: it DOES NOT work with rails 4.x . If you want to have similar functionality in your rails 4.x project - please use github.com/brain-geek/activerecord_cashier¶ ↑

This gem simplifies cache expiration in rails by adding depends_on parameter to rails cache setting, which makes cache element expire when depending object is changed.

How to use¶ ↑

Taggable-cache uses redis to store cache tags data. You can use anything for an actual cache storage. RDoc

Controller(action caching):

caches_action :index

def index
  Page.load_lot_of_data

  #this depends on any Page object change - creation, deletion, update
  depends_on Page
end

View(fragment caching):

<%# Page.active can be AR scope, every Page object on change is checked if it is in this scope, and if is - expires cache element %>
<% cache 'cache_entry', :depends_on => Page.active do %>
  <% Page.load_lot_of_data %>
<% end %>

Usage with Rails.cache:

page = Page.first
#this cache key expires only when this Page object is changed/deleted
Rails.cache.write('key', 'value', :depends_on => page)

Usage with cells gem:

class TabsCell < Cell::Rails
  cache :index, nil, :depends_on => [Category, Metacategory, Product]

  def index
    render
  end
end

If you are using redis for cache, it is recommended to set default expire_ttl value:

config.cache_store = ActiveSupport::Cache::RedisStore.new(:expire_in => 16.hours.to_i)

What is supported¶ ↑

Rails 3.1.x and 3.2.x are both supported. Tested with rubies 1.9.3 and 2.0.0. Cache storage engines tested:

Other cache storages should work but have not been tested by author.

Customizing store backend options¶ ↑

You can set custom host/port or store in taggable:

TaggableCache.settings = {
  :store => :redis, 
  :host => '127.0.0.1', 
  :port => 6379
}

Contributing to taggable-cache¶ ↑

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet.

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it.

  • Fork the project.

  • Commit and push until you are happy with your contribution.

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2012 Alex Rozumey. See LICENSE.txt for further details.