Repository is archived
No commit activity in last 3 years
No release in over 3 years
Super simple caching for Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.6
>= 0
 Project Readme

Cached Attributes

Super simple caching for Ruby

class Product
  attr_cached :orders_count

  def orders_count
    # ...
  end

end

Choose when to use the cached value

product.orders_count        # not cached
product.cached_orders_count # cached

Force a re-cache [master]

product.cache_orders_count!

Installation

Add this line to your application’s Gemfile:

gem 'cached_attributes'

Works with any ActiveSupport cache store. For Rails, Rails.cache is used by default.

Set the cache store with:

CachedAttributes.cache = ActiveSupport::Cache::MemoryStore.new

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help: