second_level_cache 2.4.1 → 2.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 041a857d039324cda299622c23936f20fe9d83f9
4
- data.tar.gz: 5a4ce5a3a3c1638eb74f9379d0f8421008c6b834
2
+ SHA256:
3
+ metadata.gz: cf466732a8f99204779ce80418071b7132abcc8f375ca5f7e98d8c067ad55c1f
4
+ data.tar.gz: c800e784340496decd81ce340bdf32fb85938f50c25d5279f29ae11d292acd2c
5
5
  SHA512:
6
- metadata.gz: 9444daff1fdeb5378db6ea2dc3e907744f2035dada6cb9b94bf47b88fa6894639a371438a02b2577ed41459d856c2b065240e322cbc156884abfaf8409c2b3ed
7
- data.tar.gz: 1e84301c16f4129f130503e1fcc7096a19cf8213e6937cedfae1724422fc793e6246bed7f66e44fac1a757dcab2a2bb13588280abc8ac2b479ed520d5ab70171
6
+ metadata.gz: ba4fa6bd084ca3ed320597b4584eeafe7c4392b731a441a6981b648b660734685526f6899e2d4bacd8b46d6d64a3c0b7c75ed50e2b9002393b5cd1cb878041ac
7
+ data.tar.gz: d712535540abc0fdaab51fcd8e45b4f53701d2f17f4dff6c133006bba8a153a1db531544361535e62300d55bc8785aca0ffde346e60d49e0616543b03d2bd4a1
data/Gemfile CHANGED
@@ -3,5 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
-
6
+ gem "paranoia", "~> 2.2"
7
+ gem "pry"
7
8
  gem "rails", "~> 5.2.0.rc"
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SecondLevelCache
4
- VERSION = "2.4.1"
4
+ VERSION = "2.4.2"
5
5
  end
@@ -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.1
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-03-30 00:00:00.000000000 Z
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.6.11
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