second_level_cache 2.4.1 → 2.4.2
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.
- checksums.yaml +5 -5
- data/Gemfile +2 -1
- data/lib/second_level_cache/active_record/base.rb +5 -1
- data/lib/second_level_cache/version.rb +1 -1
- data/test/finder_methods_test.rb +2 -2
- data/test/model/user.rb +2 -0
- data/test/test_helper.rb +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cf466732a8f99204779ce80418071b7132abcc8f375ca5f7e98d8c067ad55c1f
|
4
|
+
data.tar.gz: c800e784340496decd81ce340bdf32fb85938f50c25d5279f29ae11d292acd2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba4fa6bd084ca3ed320597b4584eeafe7c4392b731a441a6981b648b660734685526f6899e2d4bacd8b46d6d64a3c0b7c75ed50e2b9002393b5cd1cb878041ac
|
7
|
+
data.tar.gz: d712535540abc0fdaab51fcd8e45b4f53701d2f17f4dff6c133006bba8a153a1db531544361535e62300d55bc8785aca0ffde346e60d49e0616543b03d2bd4a1
|
data/Gemfile
CHANGED
@@ -4,9 +4,13 @@ module SecondLevelCache
|
|
4
4
|
module ActiveRecord
|
5
5
|
module Base
|
6
6
|
def self.prepended(base)
|
7
|
-
base.after_commit :expire_second_level_cache, on: :destroy
|
8
7
|
base.after_commit :update_second_level_cache, on: :update
|
9
8
|
base.after_commit :write_second_level_cache, on: :create
|
9
|
+
if defined?(::Paranoia)
|
10
|
+
base.after_destroy :expire_second_level_cache
|
11
|
+
else
|
12
|
+
base.after_commit :expire_second_level_cache, on: :destroy
|
13
|
+
end
|
10
14
|
|
11
15
|
class << base
|
12
16
|
prepend ClassMethods
|
data/test/finder_methods_test.rb
CHANGED
@@ -62,14 +62,14 @@ class FinderMethodsTest < ActiveSupport::TestCase
|
|
62
62
|
def test_where_and_first_should_with_cache
|
63
63
|
@user.write_second_level_cache
|
64
64
|
assert_no_queries do
|
65
|
-
assert_equal @user, User.where(id: @user.id).first
|
65
|
+
assert_equal @user, User.unscoped.where(id: @user.id).first
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_where_and_last_should_with_cache
|
70
70
|
@user.write_second_level_cache
|
71
71
|
assert_no_queries do
|
72
|
-
assert_equal @user, User.where(id: @user.id).last
|
72
|
+
assert_equal @user, User.unscoped.where(id: @user.id).last
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
data/test/model/user.rb
CHANGED
@@ -9,6 +9,7 @@ ActiveRecord::Base.connection.create_table(:users, force: true) do |t|
|
|
9
9
|
t.integer :status, default: 0
|
10
10
|
t.integer :books_count, default: 0
|
11
11
|
t.integer :images_count, default: 0
|
12
|
+
t.datetime :deleted_at
|
12
13
|
t.timestamps null: false
|
13
14
|
end
|
14
15
|
|
@@ -28,6 +29,7 @@ end
|
|
28
29
|
class User < ActiveRecord::Base
|
29
30
|
CACHE_VERSION = 3
|
30
31
|
second_level_cache(version: CACHE_VERSION, expires_in: 3.days)
|
32
|
+
acts_as_paranoid
|
31
33
|
|
32
34
|
serialize :options, Array
|
33
35
|
serialize :json_options, JSON if ::ActiveRecord::VERSION::STRING >= "4.1.0"
|
data/test/test_helper.rb
CHANGED
@@ -6,7 +6,8 @@ require "active_support/test_case"
|
|
6
6
|
require "active_record_test_case_helper"
|
7
7
|
require "database_cleaner"
|
8
8
|
require "active_record"
|
9
|
-
|
9
|
+
require "paranoia"
|
10
|
+
require "pry"
|
10
11
|
ActiveSupport.test_order = :sorted if ActiveSupport.respond_to?(:test_order=)
|
11
12
|
# Force hook :active_record on_load event to make sure loader can work.
|
12
13
|
ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base)
|
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.4.
|
4
|
+
version: 2.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hooopo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
192
|
version: '0'
|
193
193
|
requirements: []
|
194
194
|
rubyforge_project:
|
195
|
-
rubygems_version: 2.
|
195
|
+
rubygems_version: 2.7.3
|
196
196
|
signing_key:
|
197
197
|
specification_version: 4
|
198
198
|
summary: 'SecondLevelCache is a write-through and read-through caching library inspired
|