second_level_cache 2.6.3 → 2.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +3 -3
- data/lib/second_level_cache/active_record/has_one_association.rb +1 -0
- data/lib/second_level_cache/version.rb +1 -1
- data/test/has_one_association_test.rb +4 -0
- data/test/model/post.rb +10 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9401e1e025a3e955471ae743711371608400fe8c7f451f74f8b4f73bbb7c9dd6
|
4
|
+
data.tar.gz: 47c05c11d57d26dfe5c990bf111a173d0864956d788c5c5ace70ca812ef3d629
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 516d74db202dbd5d12f866b36a16b30e763a75fa88001c4ac5ab04ce1c73a2a2e412472ceda957401f9da303094d83c5a944b9c062d69e56116abdae76359256
|
7
|
+
data.tar.gz: b0f3440ffd9333d49ac957cc1db3c988f41276d57f18f874fa84fc664134a14ba0acfcc8b9f5001bab99243ef51c2492ca2ea8fe2768ac461b398a1b06504e65
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[![Build Status](https://travis-ci.org/hooopo/second_level_cache.svg?branch=master)](https://travis-ci.org/hooopo/second_level_cache)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/hooopo/second_level_cache.svg)](https://codeclimate.com/github/hooopo/second_level_cache)
|
6
6
|
|
7
|
-
SecondLevelCache is a write-through and read-through caching library inspired by Cache Money and cache_fu, support ActiveRecord 4.
|
7
|
+
SecondLevelCache is a write-through and read-through caching library inspired by Cache Money and cache_fu, support ActiveRecord 4, ActiveRecord 5 and ActiveRecord 6.
|
8
8
|
|
9
9
|
Read-Through: Queries by ID, like `current_user.articles.find(params[:id])`, will first look in cache store and then look in the database for the results of that query. If there is a cache miss, it will populate the cache.
|
10
10
|
|
@@ -15,10 +15,10 @@ Write-Through: As objects are created, updated, and deleted, all of the caches a
|
|
15
15
|
|
16
16
|
In your gem file:
|
17
17
|
|
18
|
-
ActiveRecord 5.2:
|
18
|
+
ActiveRecord 5.2 and 6.0:
|
19
19
|
|
20
20
|
```ruby
|
21
|
-
gem 'second_level_cache', '~> 2.
|
21
|
+
gem 'second_level_cache', '~> 2.6.3'
|
22
22
|
```
|
23
23
|
|
24
24
|
ActiveRecord 5.0.x, 5.1.x:
|
@@ -11,6 +11,7 @@ module SecondLevelCache
|
|
11
11
|
|
12
12
|
through = reflection.options[:through]
|
13
13
|
record = if through
|
14
|
+
return super if klass.reflections[through.to_s].nil?
|
14
15
|
return super unless klass.reflections[through.to_s].klass.second_level_cache_enabled?
|
15
16
|
begin
|
16
17
|
reflection.klass.find(owner.send(through).read_attribute(reflection.foreign_key))
|
@@ -30,6 +30,10 @@ class HasOneAssociationTest < ActiveSupport::TestCase
|
|
30
30
|
ForkedUserLink.without_second_level_cache do
|
31
31
|
assert_queries(1) { user.forked_from_user }
|
32
32
|
end
|
33
|
+
# NoMethodError: undefined method `klass' for nil:NilClass active_record/has_one_association.rb:14:in `find_target'
|
34
|
+
hotspot = Hotspot.create(summary: "summary")
|
35
|
+
assert_equal hotspot.persisted?, true
|
36
|
+
assert_nil hotspot.topic
|
33
37
|
end
|
34
38
|
|
35
39
|
def test_has_one_with_conditions
|
data/test/model/post.rb
CHANGED
@@ -6,7 +6,17 @@ ActiveRecord::Base.connection.create_table(:posts, force: true) do |t|
|
|
6
6
|
t.integer :topic_id
|
7
7
|
end
|
8
8
|
|
9
|
+
ActiveRecord::Base.connection.create_table(:hotspots, force: true) do |t|
|
10
|
+
t.integer :post_id
|
11
|
+
t.string :summary
|
12
|
+
end
|
13
|
+
|
9
14
|
class Post < ApplicationRecord
|
10
15
|
second_level_cache
|
11
16
|
belongs_to :topic, touch: true
|
12
17
|
end
|
18
|
+
|
19
|
+
class Hotspot < ApplicationRecord
|
20
|
+
belongs_to :post, required: false
|
21
|
+
has_one :topic, through: :post
|
22
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: second_level_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hooopo
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -170,7 +170,7 @@ files:
|
|
170
170
|
homepage: https://github.com/hooopo/second_level_cache
|
171
171
|
licenses: []
|
172
172
|
metadata: {}
|
173
|
-
post_install_message:
|
173
|
+
post_install_message:
|
174
174
|
rdoc_options: []
|
175
175
|
require_paths:
|
176
176
|
- lib
|
@@ -185,8 +185,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: '0'
|
187
187
|
requirements: []
|
188
|
-
rubygems_version: 3.
|
189
|
-
signing_key:
|
188
|
+
rubygems_version: 3.1.2
|
189
|
+
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: 'SecondLevelCache is a write-through and read-through caching library inspired
|
192
192
|
by Cache Money and cache_fu, support only Rails3 and ActiveRecord. Read-Through:
|