Skip to content
This repository has been archived by the owner on May 10, 2019. It is now read-only.
/ cached_attributes Public archive

Super simple caching for Ruby

License

Notifications You must be signed in to change notification settings

ankane/cached_attributes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Stars

Watchers

Forks

Packages

No packages published

Languages