Skip to content
This repository has been archived by the owner. It is now read-only.
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 

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:

About

Super simple caching for Ruby

Resources

License

Packages

No packages published

Languages