Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,24 @@ jobs:
fail-fast: false
matrix:
ruby:
- "2.5"
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- "3.2"
- "3.3"
- "3.4"
gemfile:
- gemfiles/activesupport_5_2.gemfile
- gemfiles/activesupport_6_0.gemfile
- gemfiles/activesupport_6_1.gemfile
- gemfiles/activesupport_7_0.gemfile
- gemfiles/activesupport_7_1.gemfile
- gemfiles/activesupport_7_2.gemfile
- gemfiles/without_activesupport.gemfile
- gemfiles/dalli_3.gemfile
- gemfiles/dalli_4.gemfile
- gemfiles/dalli_5.gemfile
exclude:
- ruby: "2.5"
gemfile: gemfiles/activesupport_7_0.gemfile
- ruby: "2.6"
gemfile: gemfiles/activesupport_7_0.gemfile
- ruby: "3.0"
gemfile: gemfiles/activesupport_5_2.gemfile
- ruby: "3.0"
gemfile: gemfiles/activesupport_5_2.gemfile
# dalli 5.x requires Ruby 3.3+
- ruby: "3.1"
gemfile: gemfiles/activesupport_5_2.gemfile
gemfile: gemfiles/dalli_5.gemfile
- ruby: "3.2"
gemfile: gemfiles/activesupport_5_2.gemfile
gemfile: gemfiles/dalli_5.gemfile
services:
memcached_11211:
image: memcached
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ AllCops:
- "vendor/**/*"
DisplayCopNames: true
NewCops: disable
TargetRubyVersion: 2.5
TargetRubyVersion: 3.1
SuggestExtensions: false

Style/AsciiComments:
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.3
3.3.8
28 changes: 20 additions & 8 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
appraise "without_activesupport" do
end

appraise "activesupport_5_2" do
gem "activesupport", "~> 5.2.8.1"
appraise "activesupport_7_0" do
gem "activesupport", "~> 7.0.8"
end

appraise "activesupport_6_0" do
gem "activesupport", "~> 6.0.6.1"
appraise "activesupport_7_1" do
gem "activesupport", "~> 7.1.5"
end

appraise "activesupport_6_1" do
gem "activesupport", "~> 6.1.7.7"
appraise "activesupport_7_2" do
gem "activesupport", "~> 7.2.2"
end

appraise "activesupport_7_0" do
gem "activesupport", "~> 7.0.8.1"
# dalli version tests
appraise "dalli_3" do
gem "activesupport", "~> 7.2.2"
gem "dalli", "~> 3.2"
end

appraise "dalli_4" do
gem "activesupport", "~> 7.2.2"
gem "dalli", "~> 4.3"
end

appraise "dalli_5" do
gem "activesupport", "~> 7.2.2"
gem "dalli", "~> 5.0"
end
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,24 @@ end

## Run tests locally

```
```bash
docker compose up -d
bundle install
bundle exec appraisal install

# Run tests with specific ActiveSupport version
bundle exec appraisal activesupport_7_2 rake
bundle exec appraisal activesupport_7_1 rake
bundle exec appraisal activesupport_7_0 rake
bundle exec appraisal activesupport_6_1 rake

# Run tests with specific dalli version
bundle exec appraisal dalli_5 rake
bundle exec appraisal dalli_4 rake
bundle exec appraisal dalli_3 rake

#bundle exec appraisal activesupport_5_2 rake
#bundle exec appraisal activesupport_6_0 rake
#bundle exec appraisal activesupport_6_1 rake
#bundle exec appraisal without_activesupport rake
# Run tests without ActiveSupport
bundle exec appraisal without_activesupport rake
```

## Contributing
Expand Down
4 changes: 2 additions & 2 deletions double_write_cache_stores.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.required_ruby_version = Gem::Requirement.new(">= 2.5")
spec.required_ruby_version = Gem::Requirement.new(">= 3.1")

spec.add_runtime_dependency "dalli", "~> 3.0"
spec.add_runtime_dependency "dalli", ">= 3.0", "< 6.0"

spec.add_development_dependency "appraisal", "~> 2.5.0"
spec.add_development_dependency "bundler", "~> 2.0"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/activesupport_7_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

source "https://rubygems.org"

gem "activesupport", "~> 7.0.8.1"
gem "activesupport", "~> 7.0.8"

gemspec path: "../"
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

source "https://rubygems.org"

gem "activesupport", "~> 5.2.8.1"
gem "activesupport", "~> 7.1.5"

gemspec path: "../"
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

source "https://rubygems.org"

gem "activesupport", "~> 6.0.6.1"
gem "activesupport", "~> 7.2.2"

gemspec path: "../"
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

source "https://rubygems.org"

gem "activesupport", "~> 6.1.7.7"
gem "activesupport", "~> 7.2.2"
gem "dalli", "~> 3.2"

gemspec path: "../"
8 changes: 8 additions & 0 deletions gemfiles/dalli_4.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "activesupport", "~> 7.2.2"
gem "dalli", "~> 4.3"

gemspec path: "../"
8 changes: 8 additions & 0 deletions gemfiles/dalli_5.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "activesupport", "~> 7.2.2"
gem "dalli", "~> 5.0"

gemspec path: "../"
19 changes: 10 additions & 9 deletions spec/double_write_cache_stores/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def get_or_read(store, key)
end

shared_examples "read cache after increment or decrement example" do
before { cache_store.set(key, 10, raw: true) }
before { cache_store.set(key, "10", raw: true) }
it { expect((cache_store.read key).to_i).to eq expected_value }
end

Expand All @@ -207,7 +207,7 @@ def get_or_read(store, key)

context "when options[:initial] does not exist" do
context "when value exists" do
before { cache_store.set(key, 0, raw: true) }
before { cache_store.set(key, "0", raw: true) }
context "when amount does not exist" do
it { expect(cache_store.increment key).to eq 1 }

Expand Down Expand Up @@ -240,7 +240,7 @@ def get_or_read(store, key)
else
let(:opt) { { initial: 12_345_678 } }
context "when value exists" do
before { cache_store.set(key, 0, raw: true) }
before { cache_store.set(key, "0", raw: true) }
it { expect(cache_store.increment key, 1, opt).to eq 1 }
end
context "when value does not exist" do
Expand All @@ -260,7 +260,7 @@ def get_or_read(store, key)

context "when options[:initial] does not exist" do
context "when value exists" do
before { cache_store.set(key, 101, raw: true) }
before { cache_store.set(key, "101", raw: true) }
context "when amount does not exist" do
it { expect(cache_store.decrement key).to eq 100 }

Expand Down Expand Up @@ -293,7 +293,7 @@ def get_or_read(store, key)
else
let(:opt) { { initial: 12_345_678 } }
context "when value exists" do
before { cache_store.set(key, 101, raw: true) }
before { cache_store.set(key, "101", raw: true) }
it { expect(cache_store.decrement key, 1, opt).to eq 100 }
end
context "when value does not exist" do
Expand Down Expand Up @@ -347,12 +347,12 @@ def get_or_read(store, key)
end

describe "shard example" do
if DoubleWriteCacheStores.loaded_active_support?
if DoubleWriteCacheStores.loaded_active_support? && ActiveSupport::VERSION::MAJOR < 7
context "ActiveSupport MemCacheStore" do
options = { raw: true, expires_in: 3600 }

read_and_write_store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost:11211", options
write_only_store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost:21211", options
read_and_write_store = ActiveSupport::Cache.lookup_store(:mem_cache_store, "localhost:11211", options)
write_only_store = ActiveSupport::Cache.lookup_store(:mem_cache_store, "localhost:21211", options)

context "double cache store" do
copy_cache_store = DoubleWriteCacheStores::Client.new(read_and_write_store, write_only_store)
Expand All @@ -365,7 +365,8 @@ def get_or_read(store, key)
end
end
else
skip "Not load ActiveSupport"
as_version = DoubleWriteCacheStores.loaded_active_support? ? ActiveSupport::VERSION::STRING : "not loaded"
skip "ActiveSupport MemCacheStore requires ActiveSupport < 7 (current: #{as_version})"
end

context "Dalli::Client" do
Expand Down
Loading