second_level_cache 2.0.0.rc1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +7 -0
- data/README.md +15 -3
- data/lib/second_level_cache/version.rb +1 -1
- metadata +6 -5
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
2.0.0.rc1
|
2
|
+
-----
|
3
|
+
* ActiveRecord 4 ready!
|
4
|
+
* read multi support for preloading. `Article.includes(:user).limit(5).to_a` will fetch all articles' users from cache preferentially.
|
5
|
+
* remove dependency warning
|
6
|
+
* remove support for find_by_xx which will be removed in Rails 4.1
|
7
|
+
|
1
8
|
1.6.2
|
2
9
|
-----
|
3
10
|
* [can disable/enable fetch_by_uinq_key method]
|
data/README.md
CHANGED
@@ -17,7 +17,13 @@ Write-Through: As objects are created, updated, and deleted, all of the caches a
|
|
17
17
|
In your gem file:
|
18
18
|
|
19
19
|
```ruby
|
20
|
-
gem "second_level_cache", "~> 2.0.0"
|
20
|
+
gem "second_level_cache", "~> 2.0.0.rc1"
|
21
|
+
```
|
22
|
+
|
23
|
+
For ActiveRecord 3:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
gem "second_level_cache", "~> 1.6"
|
21
27
|
```
|
22
28
|
|
23
29
|
## Usage
|
@@ -34,8 +40,6 @@ Then it will fetch cached object in this situations:
|
|
34
40
|
|
35
41
|
```ruby
|
36
42
|
User.find(1)
|
37
|
-
User.where(:status => 1).find_by_id(1)
|
38
|
-
user.articles.find_by_id(1)
|
39
43
|
user.articles.find(1)
|
40
44
|
User.where(:status => 1).find(1)
|
41
45
|
article.user
|
@@ -130,6 +134,14 @@ user = User.fetch_by_uniq_key("hooopo", :nick_name)
|
|
130
134
|
user = User.fetch_by_uniq_key!("hooopo", :nick_name) # this will raise `ActiveRecord::RecordNotFound` Exception when nick name not exists.
|
131
135
|
```
|
132
136
|
|
137
|
+
* 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:
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
Answer.includes(:question).limit(10).order("id DESC").each{|answer| answer.question.title}
|
141
|
+
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.
|
142
|
+
```
|
143
|
+
[Details for read_multi feature](http://hooopo.writings.io/articles/a9cae5e0).
|
144
|
+
|
133
145
|
## Contributors
|
134
146
|
|
135
147
|
* [chloerei](https://github.com/chloerei)
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: second_level_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Hooopo
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -151,9 +151,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
151
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
152
|
none: false
|
153
153
|
requirements:
|
154
|
-
- - ! '
|
154
|
+
- - ! '>='
|
155
155
|
- !ruby/object:Gem::Version
|
156
|
-
version:
|
156
|
+
version: '0'
|
157
157
|
requirements: []
|
158
158
|
rubyforge_project:
|
159
159
|
rubygems_version: 1.8.25
|
@@ -185,3 +185,4 @@ test_files:
|
|
185
185
|
- test/record_marshal_test.rb
|
186
186
|
- test/require_test.rb
|
187
187
|
- test/test_helper.rb
|
188
|
+
has_rdoc:
|