README.md in second_level_cache-2.0.0.rc1 vs README.md in second_level_cache-2.0.0

- old
+ new

@@ -15,13 +15,19 @@ ## Install In your gem file: ```ruby -gem "second_level_cache", "~> 2.0.0" +gem "second_level_cache", "~> 2.0.0.rc1" ``` +For ActiveRecord 3: + +```ruby +gem "second_level_cache", "~> 1.6" +``` + ## Usage For example, cache User objects: ```ruby @@ -32,12 +38,10 @@ Then it will fetch cached object in this situations: ```ruby User.find(1) -User.where(:status => 1).find_by_id(1) -user.articles.find_by_id(1) user.articles.find(1) User.where(:status => 1).find(1) article.user ``` @@ -127,9 +131,17 @@ user = User.fetch_by_uniq_key("hooopo", :nick_name) # this also fetch from cache user = User.fetch_by_uniq_key!("hooopo", :nick_name) # this will raise `ActiveRecord::RecordNotFound` Exception when nick name not exists. ``` + +* You can use Rails's [Eager Loading](http://guides.rubyonrails.org/active_record_querying.html#eager-loading-associations) feature as normal. Even better, second_level_cache will transform the `IN` query into a Rails.cache.multi_read operation. For example: + +```ruby +Answer.includes(:question).limit(10).order("id DESC").each{|answer| answer.question.title} +Answer Load (0.2ms) SELECT `answers`.* FROM `answers` ORDER BY id DESC LIMIT 10 # Only one SQL query and one Rails.cache.read_multi fetching operation. +``` +[Details for read_multi feature](http://hooopo.writings.io/articles/a9cae5e0). ## Contributors * [chloerei](https://github.com/chloerei) * [reyesyang](https://github.com/reyesyang)