Skip to content

Commit ff458c2

Browse files
Update the redis .multi code to remove the warnings in the logs
1 parent 3940ebe commit ff458c2

File tree

6 files changed

+25
-16
lines changed

6 files changed

+25
-16
lines changed

.github/workflows/rspec.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ jobs:
66
test:
77
runs-on: ubuntu-latest
88

9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
ruby-version: ['3.2', '3.1', '3.0']
13+
914
services:
1015
redis:
1116
image: redis:alpine
@@ -18,10 +23,12 @@ jobs:
1823
- 6379:6379
1924

2025
steps:
21-
- uses: actions/checkout@v3
22-
- uses: ruby/setup-ruby@v1
26+
- uses: actions/checkout@v4
27+
28+
- name: Set up Ruby ${{ matrix.ruby-version }}
29+
uses: ruby/setup-ruby@v1
2330
with:
24-
ruby-version: 2.4
31+
ruby-version: ${{ matrix.ruby-version }}
2532
bundler-cache: true
2633

2734
- name: Run tests

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ruby:2.7-buster
1+
FROM ruby:3.2
22

33
ARG BUNDLE_SAGEONEGEMS__JFROG__IO
44

cache_store_redis.gemspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Gem::Specification.new do |spec|
1313
spec.homepage = 'https://github.com/sage/cache_store'
1414
spec.license = 'MIT'
1515

16+
spec.required_ruby_version = '>= 3.0'
17+
1618
spec.files = Dir.glob("{bin,lib}/**/**/**")
1719
spec.bindir = 'exe'
1820
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }

lib/cache_store_redis/redis_cache_store.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ def set(key, value, expires_in = DEFAULT_TTL)
7575
expire_value = expiry_int.positive? ? expiry_int : Integer(DEFAULT_TTL)
7676

7777
with_client do |client|
78-
client.multi do
79-
client.set(k, v)
78+
client.multi do |transaction|
79+
transaction.set(k, v)
8080

81-
client.expire(k, expire_value)
81+
transaction.expire(k, expire_value)
8282
end
8383
end
8484
end

lib/cache_store_redis/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module CacheStoreRedis
2-
VERSION = '2.4.1'
2+
VERSION = '2.4.2'
33
end

spec/cache_store_redis_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@
88
let(:value) { 'SomeValue' }
99

1010
it 'will always set a default TTL if one is not provided' do
11-
expect_any_instance_of(Redis).to receive(:set).with("test:#{key}", "\"#{value}\"")
12-
expect_any_instance_of(Redis).to receive(:expire).with("test:#{key}", 3_600)
11+
expect_any_instance_of(Redis::MultiConnection).to receive(:set).with("test:#{key}", "\"#{value}\"")
12+
expect_any_instance_of(Redis::MultiConnection).to receive(:expire).with("test:#{key}", 3_600)
1313
subject.public_send(method_name, key, value)
1414
end
1515

1616
it 'will always set a default TTL if an invalid one is provided' do
17-
expect_any_instance_of(Redis).to receive(:set).with("test:#{key}", "\"#{value}\"")
18-
expect_any_instance_of(Redis).to receive(:expire).with("test:#{key}", 3_600)
17+
expect_any_instance_of(Redis::MultiConnection).to receive(:set).with("test:#{key}", "\"#{value}\"")
18+
expect_any_instance_of(Redis::MultiConnection).to receive(:expire).with("test:#{key}", 3_600)
1919
subject.public_send(method_name, key, value, -200)
2020
end
2121

2222
it 'will always set a default TTL if an invalid one is provided' do
23-
expect_any_instance_of(Redis).to receive(:set).with("test:#{key}", "\"#{value}\"")
24-
expect_any_instance_of(Redis).to receive(:expire).with("test:#{key}", 3_600)
23+
expect_any_instance_of(Redis::MultiConnection).to receive(:set).with("test:#{key}", "\"#{value}\"")
24+
expect_any_instance_of(Redis::MultiConnection).to receive(:expire).with("test:#{key}", 3_600)
2525
subject.public_send(method_name, key, value, 0.456)
2626
end
2727

2828
it 'will always force the TTL to be an integer' do
29-
expect_any_instance_of(Redis).to receive(:set).with("test:#{key}", "\"#{value}\"")
30-
expect_any_instance_of(Redis).to receive(:expire).with("test:#{key}", 20)
29+
expect_any_instance_of(Redis::MultiConnection).to receive(:set).with("test:#{key}", "\"#{value}\"")
30+
expect_any_instance_of(Redis::MultiConnection).to receive(:expire).with("test:#{key}", 20)
3131
subject.public_send(method_name, key, value, 20.123)
3232
end
3333
end

0 commit comments

Comments
 (0)