Super simple caching for Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
.gitignore
Gemfile
LICENSE.txt
README.md
Rakefile
cached_attributes.gemspec

README.md

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: