double_write_cache_stores 0.4.0 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 13d2f0ce282efcf499bf8fb33bbfead44f82d2d3
4
- data.tar.gz: e5b840f484ca4cabb14ce53c952132f57b42709f
2
+ SHA256:
3
+ metadata.gz: '09e3ef0241622ad655a775f6eb0cbb8ad558449935e2fcc3e023f1ab9afcc3b7'
4
+ data.tar.gz: 0ab94920920dc1d8debbae83a303a647a8730b8a066755990274b76498a6bae8
5
5
  SHA512:
6
- metadata.gz: 5838cbbac0c8a973188aa26a85dea08895a2479049d9003b5c940220a05884b5f08c07dfab26c7caa4aa9b676f7239c3e4a015385d8dda3d10434f463a05349d
7
- data.tar.gz: 9a1acfaf37c69dccd577ca88c2f58ff230cdf4e6d5d5c3391a599b240ae7cd1445cf7a9a3b4428556771e362a63e6071159814dc39f44e3c4cdbfcbff91218f5
6
+ metadata.gz: f728dd727b40ad69ce8238fcfe9c0ca8826612c16bdf8b7a870c4396a2eab3991a388b436d2fdd03ccefa913b6343603e114f5b408fe40f92949d4ff5218bec8
7
+ data.tar.gz: 05004ee53248b487720fb6fff66f57288ab05090a94904f1a7ce52fce11c62cf3d630b038a7d45a793659845b259f91e340ab07197a80f168abf5d5b1e663548
data/.codeclimate.yml ADDED
@@ -0,0 +1,7 @@
1
+ languages:
2
+ Ruby: true
3
+ JavaScript: false
4
+ Python: false
5
+ PHP: false
6
+ exclude_paths:
7
+ - "vendor/*"
@@ -0,0 +1,60 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ concurrency:
8
+ group: ${{ github.workflow }}-${{ github.ref }}
9
+ cancel-in-progress: true
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ ruby:
18
+ - "2.5"
19
+ - "2.6"
20
+ - "2.7"
21
+ - "3.0"
22
+ - "3.1"
23
+ - "3.2"
24
+ gemfile:
25
+ - gemfiles/activesupport_5_2.gemfile
26
+ - gemfiles/activesupport_6_0.gemfile
27
+ - gemfiles/activesupport_6_1.gemfile
28
+ - gemfiles/activesupport_7_0.gemfile
29
+ - gemfiles/without_activesupport.gemfile
30
+ exclude:
31
+ - ruby: "2.5"
32
+ gemfile: gemfiles/activesupport_7_0.gemfile
33
+ - ruby: "2.6"
34
+ gemfile: gemfiles/activesupport_7_0.gemfile
35
+ - ruby: "3.0"
36
+ gemfile: gemfiles/activesupport_5_2.gemfile
37
+ - ruby: "3.0"
38
+ gemfile: gemfiles/activesupport_5_2.gemfile
39
+ - ruby: "3.1"
40
+ gemfile: gemfiles/activesupport_5_2.gemfile
41
+ - ruby: "3.2"
42
+ gemfile: gemfiles/activesupport_5_2.gemfile
43
+ services:
44
+ memcached_11211:
45
+ image: memcached
46
+ ports:
47
+ - 11211:11211
48
+ memcached_21211:
49
+ image: memcached
50
+ ports:
51
+ - 21211:11211
52
+ env:
53
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
54
+ steps:
55
+ - uses: actions/checkout@v4
56
+ - uses: ruby/setup-ruby@v1
57
+ with:
58
+ ruby-version: ${{ matrix.ruby }}
59
+ bundler-cache: true
60
+ - run: bundle exec rake
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ test/version_tmp
17
17
  tmp
18
18
  bin/
19
19
  vendor
20
+ /gemfiles/*.lock
data/.rubocop.yml CHANGED
@@ -2,17 +2,17 @@ AllCops:
2
2
  Exclude:
3
3
  - "vendor/**/*"
4
4
  DisplayCopNames: true
5
+ NewCops: disable
6
+ TargetRubyVersion: 2.5
7
+ SuggestExtensions: false
5
8
 
6
9
  Style/AsciiComments:
7
10
  Enabled: false
8
11
 
9
- Style/BracesAroundHashParameters:
10
- Enabled: false
11
-
12
12
  Style/Documentation:
13
13
  Enabled: false
14
14
 
15
- Style/ExtraSpacing:
15
+ Layout/ExtraSpacing:
16
16
  Enabled: false
17
17
 
18
18
  Style/GuardClause:
@@ -27,11 +27,11 @@ Style/ModuleFunction:
27
27
  Style/StringLiterals:
28
28
  EnforcedStyle: double_quotes
29
29
 
30
- Style/SingleSpaceBeforeFirstArg:
30
+ Layout/SpaceBeforeFirstArg:
31
31
  Enabled: false
32
32
 
33
- Style/IndentationConsistency:
34
- EnforcedStyle: rails
33
+ Layout/IndentationConsistency:
34
+ EnforcedStyle: indented_internal_methods
35
35
 
36
36
  Style/SignalException:
37
37
  EnforcedStyle: only_raise
@@ -42,19 +42,50 @@ Style/HashSyntax:
42
42
  - "**/*.rake"
43
43
  - "Rakefile"
44
44
 
45
- Metrics/LineLength:
45
+ Layout/LineLength:
46
46
  Max: 160
47
- Exclude:
48
- - "db/migrate/*.rb"
49
47
 
50
- NumericLiterals:
48
+ Style/NumericLiterals:
51
49
  MinDigits: 7
52
50
 
53
51
  Lint/AssignmentInCondition:
54
52
  Enabled: false
55
53
 
56
- Lint/BlockAlignment:
54
+ Layout/BlockAlignment:
57
55
  Enabled: false
58
56
 
59
57
  Metrics/MethodLength:
60
- Max: 12
58
+ Enabled: false
59
+
60
+ Style/FrozenStringLiteralComment:
61
+ Enabled: false
62
+
63
+ Style/NestedParenthesizedCalls:
64
+ Enabled: false
65
+
66
+ Metrics/BlockLength:
67
+ Enabled: false
68
+
69
+ Layout/EmptyLineAfterGuardClause:
70
+ Enabled: false
71
+
72
+ Style/MutableConstant:
73
+ Enabled: false
74
+
75
+ Style/ExpandPathArguments:
76
+ Enabled: false
77
+
78
+ Style/Alias:
79
+ Enabled: false
80
+
81
+ Style/SafeNavigation:
82
+ Enabled: false
83
+
84
+ Style/IfUnlessModifier:
85
+ Enabled: false
86
+
87
+ Style/ExplicitBlockArgument:
88
+ Enabled: false
89
+
90
+ Lint/AmbiguousBlockAssociation:
91
+ Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.3
1
+ 3.2.3
data/Appraisals ADDED
@@ -0,0 +1,18 @@
1
+ appraise "without_activesupport" do
2
+ end
3
+
4
+ appraise "activesupport_5_2" do
5
+ gem "activesupport", "~> 5.2.8.1"
6
+ end
7
+
8
+ appraise "activesupport_6_0" do
9
+ gem "activesupport", "~> 6.0.6.1"
10
+ end
11
+
12
+ appraise "activesupport_6_1" do
13
+ gem "activesupport", "~> 6.1.7.7"
14
+ end
15
+
16
+ appraise "activesupport_7_0" do
17
+ gem "activesupport", "~> 7.0.8.1"
18
+ end
data/README.md CHANGED
@@ -1,13 +1,12 @@
1
1
  # DoubleWriteCacheStores
2
2
 
3
- [![Build Status](https://travis-ci.org/hirocaster/double_write_cache_stores.svg?branch=master)](https://travis-ci.org/hirocaster/double_write_cache_stores)
3
+ [![test](https://github.com/mixigroup/double_write_cache_stores/actions/workflows/test.yml/badge.svg)](https://github.com/mixigroup/double_write_cache_stores/actions/workflows/test.yml)
4
4
 
5
5
  pre-warming(double write to cach store and other cache store) cache store wrapper. will switch cache store.
6
6
 
7
7
  ## Support backend cache store
8
8
 
9
9
  - ActiveSupport::Cache::MemCacheStore
10
- - ActiveSupport::Cache::DalliStore in Dalli
11
10
  - Dalli::Client
12
11
 
13
12
  ## Installation
@@ -60,9 +59,23 @@ Rails.cache.fetch("key") do
60
59
  end
61
60
  ```
62
61
 
62
+ ## Run tests locally
63
+
64
+ ```
65
+ docker compose up -d
66
+ bundle install
67
+ bundle exec appraisal install
68
+ bundle exec appraisal activesupport_7_0 rake
69
+
70
+ #bundle exec appraisal activesupport_5_2 rake
71
+ #bundle exec appraisal activesupport_6_0 rake
72
+ #bundle exec appraisal activesupport_6_1 rake
73
+ #bundle exec appraisal without_activesupport rake
74
+ ```
75
+
63
76
  ## Contributing
64
77
 
65
- 1. Fork it ( http://github.com/hirocaster/double_write_cache_stores/fork )
78
+ 1. Fork it ( http://github.com/mixigroup/double_write_cache_stores/fork )
66
79
  2. Create your feature branch (`git checkout -b my-new-feature`)
67
80
  3. Commit your changes (`git commit -am 'Add some feature'`)
68
81
  4. Push to the branch (`git push origin my-new-feature`)
data/Rakefile CHANGED
@@ -1,6 +1,11 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require "rubocop/rake_task"
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
5
6
 
6
- task :default => :spec
7
+ RuboCop::RakeTask.new do |task|
8
+ task.options = %w[-c .rubocop.yml]
9
+ end
10
+
11
+ task default: %i[rubocop spec]
@@ -1,7 +1,7 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "rack"
4
3
  gem "activesupport"
4
+ gem "rack"
5
5
 
6
6
  # Specify your gem's dependencies in active_record_sharding.gemspec
7
7
  gemspec
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- double_write_cache_stores (0.3.0)
4
+ double_write_cache_stores (0.4.0)
5
5
  dalli (~> 2.7.4)
6
6
 
7
7
  GEM
data/compose.yaml ADDED
@@ -0,0 +1,9 @@
1
+ services:
2
+ memcached_11211:
3
+ image: memcached
4
+ ports:
5
+ - "11211:11211"
6
+ memcached_21211:
7
+ image: memcached
8
+ ports:
9
+ - "21211:11211"
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require "double_write_cache_stores/version"
@@ -18,11 +17,15 @@ Gem::Specification.new do |spec|
18
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
18
  spec.require_paths = ["lib"]
20
19
 
21
- spec.add_runtime_dependency "dalli", "~> 2.7.4"
20
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5")
22
21
 
23
- spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_runtime_dependency "dalli", "~> 3.0"
23
+
24
+ spec.add_development_dependency "appraisal", "~> 2.5.0"
25
+ spec.add_development_dependency "bundler", "~> 2.0"
26
+ spec.add_development_dependency "pry"
24
27
  spec.add_development_dependency "rake"
25
28
  spec.add_development_dependency "rspec"
26
- spec.add_development_dependency "pry"
29
+ spec.add_development_dependency "rubocop"
27
30
  spec.add_development_dependency "tilt", "1.3.7"
28
31
  end
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 5.2.8.1"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 6.0.6.1"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 6.1.7.7"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 7.0.8.1"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,5 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec path: "../"
@@ -21,6 +21,8 @@ module DoubleWriteCacheStores
21
21
  @read_and_write_store.get_cas key
22
22
  elsif @read_and_write_store.respond_to? :read_cas
23
23
  @read_and_write_store.read_cas key
24
+ elsif @read_and_write_store.respond_to? :dalli
25
+ @read_and_write_store.dalli.get_cas key
24
26
  end
25
27
  end
26
28
 
@@ -31,6 +33,8 @@ module DoubleWriteCacheStores
31
33
  options ||= {}
32
34
  options[:cas] = cas
33
35
  @read_and_write_store.write_cas key, value, options
36
+ elsif @read_and_write_store.respond_to? :dalli
37
+ @read_and_write_store.dalli.set_cas key, value, cas, options
34
38
  end
35
39
 
36
40
  if @write_only_store && cas_unique
@@ -51,8 +55,20 @@ module DoubleWriteCacheStores
51
55
  end
52
56
 
53
57
  def touch(key, ttl = nil)
54
- result = @read_and_write_store.touch key, ttl
55
- @write_only_store.touch key, ttl if @write_only_store
58
+ result = if @read_and_write_store.respond_to? :touch
59
+ @read_and_write_store.touch key, ttl
60
+ elsif @read_and_write_store.respond_to? :dalli
61
+ @read_and_write_store.dalli.touch key, ttl
62
+ end
63
+
64
+ if @write_only_store
65
+ if @write_only_store.respond_to? :touch
66
+ @write_only_store.touch key, ttl
67
+ elsif @write_only_store.respond_to? :dalli
68
+ @write_only_store.dalli.touch key, ttl
69
+ end
70
+ end
71
+
56
72
  result
57
73
  end
58
74
 
@@ -164,7 +180,7 @@ module DoubleWriteCacheStores
164
180
  cache_store.incr key, amount, ttl, default
165
181
  elsif cache_store.respond_to? :increment
166
182
  options[:initial] = amount unless options.key?(:initial)
167
- cache_store.increment key, amount, options
183
+ cache_store.increment key, amount, **options
168
184
  end
169
185
  end
170
186
 
@@ -175,7 +191,7 @@ module DoubleWriteCacheStores
175
191
  cache_store.decr key, amount, ttl, default
176
192
  elsif cache_store.respond_to? :decrement
177
193
  options[:initial] = 0 unless options.key?(:initial)
178
- cache_store.decrement key, amount, options
194
+ cache_store.decrement key, amount, **options
179
195
  end
180
196
  end
181
197
 
@@ -1,3 +1,3 @@
1
1
  module DoubleWriteCacheStores
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -4,7 +4,7 @@ module DoubleWriteCacheStores
4
4
  begin
5
5
  require "active_support"
6
6
  loaded_active_support = true
7
- rescue LoadError # rubocop:disable Lint/HandleExceptions
7
+ rescue LoadError # rubocop:disable Lint/SuppressedException
8
8
  end
9
9
 
10
10
  loaded_active_support.freeze
@@ -21,6 +21,5 @@ require "double_write_cache_stores/client"
21
21
  require "double_write_cache_stores/base_exception"
22
22
 
23
23
  require "dalli"
24
- require "dalli_store_patch"
25
24
 
26
25
  require "mem_cache_store_patch" if DoubleWriteCacheStores.loaded_active_support?
@@ -1,48 +1,13 @@
1
1
  # monky patch
2
- # support touch interface for ActiveSupport::Cache::MemCacheStore
3
2
  module MemCacheStorePatch
4
- def touch(name, ttl = nil)
5
- key = namespaced_key(name, options)
6
- ttl ||= options[:expires_in].to_i if options[:expires_in]
7
- @data.touch(key, ttl)
8
- rescue Dalli::DalliError => e
9
- logger.error("DalliError (#{e}): #{e.message}") if logger
10
- nil
11
- end
12
-
13
- def read_cas(name, options = nil)
14
- options ||= {}
15
- key = namespaced_key(name, options)
16
-
17
- instrument(:get_cas, key) do |_payload|
18
- @data.get_cas(key)
19
- end
20
- rescue Dalli::DalliError => e
21
- logger.error("DalliError: #{e.message}") if logger
22
- raise if raise_errors?
23
- false
24
- end
25
-
26
- def write_cas(name, value, options = nil)
27
- options ||= {}
28
- key = namespaced_key(name, options)
29
- expires_in = options[:expires_in]
30
-
31
- instrument(:set_cas, key, value) do |_payload|
32
- cas = options.delete(:cas) || 0
33
- expires_in = options.delete(:expires_in)
34
- @data.set_cas(key, value, cas, expires_in, options)
35
- end
36
- rescue Dalli::DalliError => e
37
- logger.error("DalliError: #{e.message}") if logger
38
- raise if raise_errors?
39
- false
3
+ def dalli
4
+ @data
40
5
  end
41
6
  end
42
7
 
43
8
  begin
44
9
  require "active_support/cache/mem_cache_store"
45
10
 
46
- ActiveSupport::Cache::MemCacheStore.send(:include, MemCacheStorePatch)
47
- rescue LoadError # rubocop:disable Lint/HandleExceptions
11
+ ActiveSupport::Cache::MemCacheStore.include MemCacheStorePatch
12
+ rescue LoadError # rubocop:disable Lint/SuppressedException
48
13
  end
@@ -9,7 +9,7 @@ def get_or_read(store, key)
9
9
  end
10
10
 
11
11
  describe DoubleWriteCacheStores::Client do
12
- describe '#initialize' do
12
+ describe "#initialize" do
13
13
  let(:options) { { namespace: "app_v1", compress: true } }
14
14
  it "different cache store instance" do
15
15
  expect { DoubleWriteCacheStores::Client.new Dalli::Client.new("localhost:11211", options), "bad instance object" }.to raise_error RuntimeError
@@ -40,7 +40,7 @@ describe DoubleWriteCacheStores::Client do
40
40
  end
41
41
 
42
42
  shared_examples "cache store example" do |cache_store|
43
- describe '#read_multi' do
43
+ describe "#read_multi" do
44
44
  before do
45
45
  cache_store.write "key-a", "example-value-a", expires_in: 86400
46
46
  cache_store.write "key-b", "example-value-b", expires_in: 86400
@@ -55,12 +55,12 @@ describe DoubleWriteCacheStores::Client do
55
55
  expect(results["key-c"]).to eq nil
56
56
  end
57
57
 
58
- it 'returns values equal #get_multi' do
58
+ it "returns values equal #get_multi" do
59
59
  expect(cache_store.read_multi("key-a", "key-b")).to eq cache_store.get_multi("key-a", "key-b")
60
60
  end
61
61
  end
62
62
 
63
- describe '#fetch' do
63
+ describe "#fetch" do
64
64
  before do
65
65
  cache_store.write "key-a", "example-value-a", expires_in: 1
66
66
  end
@@ -110,7 +110,7 @@ describe DoubleWriteCacheStores::Client do
110
110
  end
111
111
  end
112
112
 
113
- describe '#delete' do
113
+ describe "#delete" do
114
114
  before do
115
115
  cache_store.write "will-delete-key", "example-will-delete-value", expires_in: 86400
116
116
  expect(cache_store.delete "will-delete-key").to be true
@@ -123,7 +123,7 @@ describe DoubleWriteCacheStores::Client do
123
123
  it_behaves_like "Equal values", cache_store, "will-delete-key", nil
124
124
  end
125
125
 
126
- describe '#touch' do
126
+ describe "#touch" do
127
127
  let(:expire_ttl) { 1 }
128
128
 
129
129
  before do
@@ -152,7 +152,7 @@ describe DoubleWriteCacheStores::Client do
152
152
  end
153
153
  end
154
154
 
155
- describe '#write' do
155
+ describe "#write" do
156
156
  before do
157
157
  cache_store.write "key", "example-write-value", expires_in: 86400
158
158
  end
@@ -164,7 +164,7 @@ describe DoubleWriteCacheStores::Client do
164
164
  it_behaves_like "Equal values", cache_store, "key", "example-write-value"
165
165
  end
166
166
 
167
- describe '#read' do
167
+ describe "#read" do
168
168
  before do
169
169
  cache_store.write "key", "example-read-value", expires_in: 86400
170
170
  end
@@ -178,7 +178,7 @@ describe DoubleWriteCacheStores::Client do
178
178
  end
179
179
  end
180
180
 
181
- describe '#flush' do
181
+ describe "#flush" do
182
182
  before do
183
183
  cache_store.write "will-flush-key", "will-flush-value", expires_in: 86400
184
184
  expect(cache_store.read "will-flush-key").to eq "will-flush-value"
@@ -197,7 +197,7 @@ describe DoubleWriteCacheStores::Client do
197
197
  it { expect((cache_store.read key).to_i).to eq expected_value }
198
198
  end
199
199
 
200
- describe '#increment' do
200
+ describe "#increment" do
201
201
  let(:key) { "key-increment" }
202
202
  after { cache_store.flush }
203
203
 
@@ -250,7 +250,7 @@ describe DoubleWriteCacheStores::Client do
250
250
  end
251
251
  end
252
252
 
253
- describe '#decrement' do
253
+ describe "#decrement" do
254
254
  let(:key) { "key-decrement" }
255
255
  after { cache_store.flush }
256
256
 
@@ -303,7 +303,7 @@ describe DoubleWriteCacheStores::Client do
303
303
  end
304
304
  end
305
305
 
306
- describe '#[]=(key,value) and get #[](key)' do
306
+ describe "#[]=(key,value) and get #[](key)" do
307
307
  it "set value and get value" do
308
308
  cache_store["key"] = "example-value"
309
309
  expect(cache_store["key"]).to eq "example-value"
@@ -316,7 +316,7 @@ describe DoubleWriteCacheStores::Client do
316
316
  end
317
317
 
318
318
  describe "cas" do
319
- describe '#get_cas' do
319
+ describe "#get_cas" do
320
320
  before do
321
321
  cache_store.set_cas "get-cas-key", "get-cas-value"
322
322
  end
@@ -329,7 +329,7 @@ describe DoubleWriteCacheStores::Client do
329
329
  it_behaves_like("Equal values", cache_store, "get-cas-key", "get-cas-value")
330
330
  end
331
331
 
332
- describe '#set_cas' do
332
+ describe "#set_cas" do
333
333
  let :cas_unique do
334
334
  cache_store.set_cas("set-cas-key", "set-cas-value")
335
335
  cache_store.get_cas("set-cas-key")[1]
@@ -364,21 +364,6 @@ describe DoubleWriteCacheStores::Client do
364
364
  it_behaves_like "cache store example", one_cache_store
365
365
  end
366
366
  end
367
-
368
- context "ActiveSupport :dalli_store in Dalli" do
369
- read_and_write_store = ActiveSupport::Cache.lookup_store :dalli_store, "localhost:11211"
370
- write_only_store = ActiveSupport::Cache.lookup_store :dalli_store, "localhost:21211"
371
-
372
- context "double cache store" do
373
- copy_cache_store = DoubleWriteCacheStores::Client.new(read_and_write_store, write_only_store)
374
- it_behaves_like "cache store example", copy_cache_store
375
- end
376
-
377
- context "one cache store object" do
378
- one_cache_store = DoubleWriteCacheStores::Client.new(read_and_write_store, nil)
379
- it_behaves_like "cache store example", one_cache_store
380
- end
381
- end
382
367
  else
383
368
  skip "Not load ActiveSupport"
384
369
  end
data/spec/spec_helper.rb CHANGED
@@ -3,23 +3,4 @@ require "pry"
3
3
  $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
4
4
  require "double_write_cache_stores"
5
5
  require "dalli"
6
- require "dalli/cas/client"
7
-
8
- PID_DIR = File.expand_path(File.dirname(__FILE__) + "/../tmp/pids")
9
- PORTS = [11211, 21211]
10
-
11
- RSpec.configure do |conf|
12
- FileUtils.mkdir_p PID_DIR
13
-
14
- PORTS.each do |port|
15
- pid = File.expand_path(PID_DIR + "/memcached-spec-#{port}.pid")
16
- ` memcached -d -p #{port} -P #{pid} `
17
- end
18
-
19
- conf.after(:suite) do
20
- PORTS.each do |port|
21
- pid = File.expand_path(PID_DIR + "/memcached-spec-#{port}.pid")
22
- ` cat #{pid} | xargs kill -9 `
23
- end
24
- end
25
- end
6
+ require "dalli/client"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: double_write_cache_stores
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - hirocaster
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-13 00:00:00.000000000 Z
11
+ date: 2024-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dalli
@@ -16,28 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.7.4
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.7.4
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: appraisal
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.5.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.5.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '1.5'
47
+ version: '2.0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '1.5'
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: rake
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +95,7 @@ dependencies:
67
95
  - !ruby/object:Gem::Version
68
96
  version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
- name: pry
98
+ name: rubocop
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - ">="
@@ -102,19 +130,26 @@ executables: []
102
130
  extensions: []
103
131
  extra_rdoc_files: []
104
132
  files:
133
+ - ".codeclimate.yml"
134
+ - ".github/workflows/test.yml"
105
135
  - ".gitignore"
106
136
  - ".rspec"
107
137
  - ".rubocop.yml"
108
138
  - ".ruby-version"
109
- - ".travis.yml"
139
+ - Appraisals
110
140
  - Gemfile
111
141
  - LICENSE.txt
112
142
  - README.md
113
143
  - Rakefile
114
144
  - activesupport.gemfile
115
145
  - activesupport.gemfile.lock
146
+ - compose.yaml
116
147
  - double_write_cache_stores.gemspec
117
- - lib/dalli_store_patch.rb
148
+ - gemfiles/activesupport_5_2.gemfile
149
+ - gemfiles/activesupport_6_0.gemfile
150
+ - gemfiles/activesupport_6_1.gemfile
151
+ - gemfiles/activesupport_7_0.gemfile
152
+ - gemfiles/without_activesupport.gemfile
118
153
  - lib/double_write_cache_stores.rb
119
154
  - lib/double_write_cache_stores/base_exception.rb
120
155
  - lib/double_write_cache_stores/client.rb
@@ -135,15 +170,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
170
  requirements:
136
171
  - - ">="
137
172
  - !ruby/object:Gem::Version
138
- version: '0'
173
+ version: '2.5'
139
174
  required_rubygems_version: !ruby/object:Gem::Requirement
140
175
  requirements:
141
176
  - - ">="
142
177
  - !ruby/object:Gem::Version
143
178
  version: '0'
144
179
  requirements: []
145
- rubyforge_project:
146
- rubygems_version: 2.5.0
180
+ rubygems_version: 3.4.19
147
181
  signing_key:
148
182
  specification_version: 4
149
183
  summary: Double write cache stores wrapper.
data/.travis.yml DELETED
@@ -1,21 +0,0 @@
1
- language: ruby
2
- install: bundle install --jobs=3 --retry=3
3
- cache:
4
- directories:
5
- - vendor/bundle
6
- rvm:
7
- - 2.2.3
8
- - 2.1.7
9
- - 2.0.0-p647
10
-
11
- gemfile:
12
- - Gemfile
13
- - activesupport.gemfile
14
-
15
- addons:
16
- apt:
17
- packages:
18
- - memcached
19
-
20
- script:
21
- - bundle exec rake spec
@@ -1,42 +0,0 @@
1
- # monky patch
2
- # support cas interface for ActiveSupport::Cache::DalliStore
3
- module DalliStorePatch
4
- def touch(key, ttl = nil)
5
- ttl ||= options[:expires_in].to_i
6
- @data.touch key, ttl
7
- end
8
-
9
- def read_cas(name, options = {})
10
- name = namespaced_key(name, options)
11
-
12
- instrument(:get_cas, name) do |_payload|
13
- with { |c| c.get_cas(name) }
14
- end
15
- rescue Dalli::DalliError => e
16
- logger.error("DalliError: #{e.message}") if logger
17
- raise if raise_errors?
18
- false
19
- end
20
-
21
- def write_cas(name, value, options = {})
22
- name = namespaced_key(name, options)
23
- expires_in = options[:expires_in]
24
-
25
- instrument(:set_cas, name, value) do |_payload|
26
- cas = options.delete(:cas) || 0
27
- expires_in = options.delete(:expires_in)
28
- with { |c| c.set_cas(name, value, cas, expires_in, options) }
29
- end
30
- rescue Dalli::DalliError => e
31
- logger.error("DalliError: #{e.message}") if logger
32
- raise if raise_errors?
33
- false
34
- end
35
- end
36
-
37
- begin
38
- require "active_support/cache/dalli_store"
39
-
40
- ActiveSupport::Cache::DalliStore.send(:include, DalliStorePatch)
41
- rescue LoadError # rubocop:disable Lint/HandleExceptions
42
- end