redis-store 1.9.1 → 1.10.0

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
2
  SHA256:
3
- metadata.gz: f1313af60d82044041ee37781a16eb734332476e45ce6bc59d6c2ffa4e90c1d5
4
- data.tar.gz: b17aa7cf4cc0439c2e1ee460dd15c4f16a43963370a742c9a3c9180dc970d5dc
3
+ metadata.gz: 90b9775d198eedd8f7fbfbf48548ea825bf888a80bf430be0b7124d9092b6f7a
4
+ data.tar.gz: bfa57fa72dafc2bf60885da2501cd377eaceb45892a5e21ca9515d378556f95a
5
5
  SHA512:
6
- metadata.gz: ff9ea84a0b8daf75b59883ab6d2040a3726caaf43249d52661d1d9aa335ac2c25c7e53c351d45c81f2009b50a34d07bbe6a3d408d2701bdc7c7301959c2cb4dc
7
- data.tar.gz: bccc369d3d57af1dcec02e1797b1e8527b3993c051c6ff3db60556638529630adbc3ba5a7b4d53b08ebe991f145abb7eaac37873fac734ca6c4bd6ec0ea31074
6
+ metadata.gz: c4c0e067c7e20907158913fa39dbc86abc5c5b3a8120f966e2f311dcb3ae380596c824d0bfcb9385ca77681e8fb98d06ff63f45c289dfb51a1916d5448fe7ab4
7
+ data.tar.gz: d6e2d2bc963b99870f4a4abe0e20ede46dc3177f214685922aa0313e8baa9f2879d1fadd1d7786b5ce6d7dc9b736ee7a1ee74664041bbf4479347e96c44b0421
@@ -0,0 +1,13 @@
1
+ changelog:
2
+ exclude:
3
+ labels: [dependencies]
4
+ authors: [renovate-bot]
5
+ categories:
6
+ - title: Breaking Changes
7
+ labels: [breaking]
8
+ - title: New Features
9
+ labels: [enhancement]
10
+ - title: Bug Fixes
11
+ labels: [bug]
12
+ - title: Other Changes
13
+ labels: ["*"]
@@ -0,0 +1,64 @@
1
+ name: CI
2
+ on:
3
+ pull_request:
4
+ push:
5
+ branches-ignore: [master]
6
+ tags-ignore: [v*]
7
+ concurrency:
8
+ group: ${{ github.workflow }}-${{ github.ref }}
9
+ cancel-in-progress: true
10
+ jobs:
11
+ test:
12
+ name: "test (ruby: ${{ matrix.ruby }}, redis.rb: ${{ matrix.redis }})"
13
+ runs-on: ubuntu-latest
14
+ continue-on-error: ${{ contains(matrix.ruby, 'head') }}
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ ruby:
19
+ - "2.7"
20
+ - "3.0"
21
+ - "3.1"
22
+ # - 'head'
23
+ - "jruby"
24
+ # - 'jruby-head'
25
+ - "truffleruby"
26
+ # - 'truffleruby-head'
27
+ redis:
28
+ - 4_0_x
29
+ - 4_1_x
30
+ - 4_x
31
+ - 5_x
32
+ env:
33
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/redis_${{ matrix.redis }}.gemfile
34
+ services:
35
+ redis:
36
+ image: redis
37
+ ports:
38
+ - 6379:6379
39
+ distributed1:
40
+ image: redis
41
+ ports:
42
+ - 6380:6380
43
+ distributed2:
44
+ image: redis
45
+ ports:
46
+ - 6381:6381
47
+ steps:
48
+ - uses: actions/checkout@v3
49
+ - uses: ruby/setup-ruby@v1
50
+ with:
51
+ ruby-version: ${{ matrix.ruby }}
52
+ bundler-cache: true
53
+ - run: bundle exec rake
54
+ lint:
55
+ runs-on: ubuntu-latest
56
+ steps:
57
+ - uses: actions/checkout@v3
58
+ with:
59
+ fetch-depth: 0
60
+ - uses: ruby/setup-ruby@v1
61
+ with:
62
+ ruby-version: 3.1
63
+ bundler-cache: true
64
+ - run: bundle exec rake lint
@@ -0,0 +1,32 @@
1
+ name: Publish
2
+ on:
3
+ push:
4
+ tags: [v*]
5
+ permissions:
6
+ contents: write
7
+ concurrency:
8
+ group: ${{ github.workflow }}-${{ github.ref }}
9
+ cancel-in-progress: true
10
+ jobs:
11
+ release:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: "3.1"
18
+ bundle-cache: true
19
+ - run: |
20
+ mkdir -p ~/.gem
21
+ cat << EOF > ~/.gem/credentials
22
+ ---
23
+ :rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}
24
+ EOF
25
+
26
+ chmod 0600 ~/.gem/credentials
27
+ - run: bundle exec rake release
28
+ - uses: softprops/action-gh-release@v1
29
+ with:
30
+ files: "*.gem"
31
+ generate_release_notes: true
32
+ prerelease: ${{ contains(github.ref, '.pre') }}
data/.gitignore CHANGED
@@ -4,3 +4,6 @@ tmp/
4
4
  stdout
5
5
  # Gemfile locks generated by Appraisals
6
6
  gemfiles/*.gemfile.lock
7
+ gemfiles/.bundle/
8
+ # ASDF
9
+ .tool-versions
data/.rubocop.yml CHANGED
@@ -5,18 +5,12 @@ AllCops:
5
5
  # to ignore them, so only the ones explicitly set in this file are enabled.
6
6
  DisabledByDefault: true
7
7
  Exclude:
8
- - '**/vendor/**/*'
8
+ - "**/vendor/**/*"
9
9
 
10
10
  # Prefer &&/|| over and/or.
11
11
  Style/AndOr:
12
12
  Enabled: true
13
13
 
14
- # Do not use braces for hash literals when they are the last argument of a
15
- # method call.
16
- Style/BracesAroundHashParameters:
17
- Enabled: true
18
- EnforcedStyle: context_dependent
19
-
20
14
  # Align comments with method definitions.
21
15
  Layout/CommentIndentation:
22
16
  Enabled: true
@@ -46,7 +40,7 @@ Layout/FirstParameterIndentation:
46
40
  # extra level of indentation.
47
41
  Layout/IndentationConsistency:
48
42
  Enabled: true
49
- EnforcedStyle: rails
43
+ EnforcedStyle: indented_internal_methods
50
44
 
51
45
  # Two spaces, no tabs (for indentation).
52
46
  Layout/IndentationWidth:
@@ -99,11 +93,11 @@ Layout/SpaceInsideParens:
99
93
  Enabled: true
100
94
 
101
95
  # Detect hard tabs, no hard tabs.
102
- Layout/Tab:
96
+ Layout/IndentationStyle:
103
97
  Enabled: true
104
98
 
105
99
  # Blank lines should not have any spaces.
106
- Layout/TrailingBlankLines:
100
+ Layout/TrailingEmptyLines:
107
101
  Enabled: true
108
102
 
109
103
  # No trailing whitespace.
@@ -111,7 +105,7 @@ Layout/TrailingWhitespace:
111
105
  Enabled: true
112
106
 
113
107
  # Use quotes for string literals when they are enough.
114
- Style/UnneededPercentQ:
108
+ Style/RedundantPercentQ:
115
109
  Enabled: true
116
110
 
117
111
  # Align `end` with the matching keyword or starting expression except for
data/Appraisals CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  appraise "redis_4_0_x" do
3
2
  gem "redis", "~> 4.0.0"
4
3
  end
@@ -7,6 +6,14 @@ appraise "redis_4_1_x" do
7
6
  gem "redis", "~> 4.1.0"
8
7
  end
9
8
 
9
+ appraise "redis_4_6_x" do
10
+ gem "redis", "~> 4.6.0"
11
+ end
12
+
10
13
  appraise "redis_4_x" do
11
14
  gem "redis", "~> 4.0"
12
15
  end
16
+
17
+ appraise "redis_5_x" do
18
+ gem "redis", "~> 5.0"
19
+ end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.10.0 and future
4
+
5
+ As at 1.10 and above, changelog information will be on this project's releases page:
6
+
7
+ https://github.com/redis-store/redis-store/releases
8
+
9
+
3
10
  ## 1.9.0
4
11
 
5
12
  Breaking Changes
data/README.md CHANGED
@@ -46,7 +46,7 @@ s.add_dependency 'redis-store', '>= 1.4', '< 2'
46
46
  ## Status
47
47
 
48
48
  [![Gem Version](https://badge.fury.io/rb/redis-store.svg)](http://badge.fury.io/rb/redis-store)
49
- [![Build Status](https://secure.travis-ci.org/redis-store/redis-store.svg?branch=master)](http://travis-ci.org/redis-store/redis-store?branch=master)
49
+ [![Build Status](https://github.com/redis-store/redis-store/actions/workflows/ci.yml/badge.svg)](https://github.com/redis-store/redis-store/actions/workflows/ci.yml)
50
50
  [![Code Climate](https://codeclimate.com/github/redis-store/redis-store.svg)](https://codeclimate.com/github/redis-store/redis-store)
51
51
 
52
52
  ## Copyright
data/Rakefile CHANGED
@@ -1,14 +1,15 @@
1
1
  require 'bundler/setup'
2
2
  require 'rake'
3
3
  require 'bundler/gem_tasks'
4
- require 'redis-store/testing/tasks'
5
4
  require 'appraisal'
6
5
  require 'rubocop/rake_task'
7
6
 
8
7
  RuboCop::RakeTask.new :lint
9
8
 
10
- if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
9
+ if !ENV["APPRAISAL_INITIALIZED"] && !ENV["CI"]
11
10
  task :default do
12
11
  sh "appraisal install && rake appraisal default"
13
12
  end
13
+ else
14
+ require 'redis-store/testing/tasks'
14
15
  end
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "redis", "~> 4.6.0"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "redis", "~> 5.0"
6
+
7
+ gemspec path: "../"
@@ -7,6 +7,8 @@ class Redis
7
7
 
8
8
  def initialize(addresses, options = {})
9
9
  _extend_namespace options
10
+ # `@tag` introduced in `redis-rb` 5.0
11
+ @tag = options[:tag] || /^\{(.+?)\}/
10
12
  @ring = options[:ring] || Redis::HashRing.new([], options[:replicas] || Redis::HashRing::POINTS_PER_SERVER)
11
13
 
12
14
  addresses.each do |address|
@@ -1,3 +1,4 @@
1
+ require 'cgi'
1
2
  require 'uri'
2
3
 
3
4
  class Redis
@@ -47,7 +47,7 @@ class Redis
47
47
  if match
48
48
  namespace(match) do |pattern|
49
49
  cursor, keys = super(cursor, match: pattern, **kwargs)
50
- [ cursor, keys.map{ |key| strip_namespace(key) } ]
50
+ [ cursor, keys.map { |key| strip_namespace(key) } ]
51
51
  end
52
52
  else
53
53
  super(cursor, **kwargs)
@@ -20,8 +20,13 @@ class Redis
20
20
  protected
21
21
  def setnx_with_expire(key, value, ttl, options = {})
22
22
  with_multi_or_pipelined(options) do |transaction|
23
- transaction.setnx(key, value, :raw => true)
24
- transaction.expire(key, ttl)
23
+ if transaction.is_a?(Redis::Store) # for redis < 4.6
24
+ setnx(key, value, :raw => true)
25
+ expire(key, ttl)
26
+ else
27
+ transaction.setnx(key, value)
28
+ transaction.expire(key, ttl)
29
+ end
25
30
  end
26
31
  end
27
32
 
@@ -1,5 +1,12 @@
1
1
  class Redis
2
2
  class Store < self
3
- VERSION = '1.9.1'
3
+ VERSION = '1.10.0'
4
+
5
+ def self.redis_client_defined?
6
+ # Doesn't work if declared as constant
7
+ # due to unpredictable gem loading order
8
+ # https://github.com/redis-rb/redis-client
9
+ defined?(::RedisClient::VERSION)
10
+ end
4
11
  end
5
12
  end
data/lib/redis/store.rb CHANGED
@@ -14,9 +14,13 @@ class Redis
14
14
  include Ttl, Interface, RedisVersion
15
15
 
16
16
  def initialize(options = {})
17
- super
17
+ orig_options = options.dup
18
18
 
19
- unless options[:marshalling].nil?
19
+ _remove_unsupported_options(options)
20
+ # The options here is updated
21
+ super(options)
22
+
23
+ unless orig_options[:marshalling].nil?
20
24
  puts %(
21
25
  DEPRECATED: You are passing the :marshalling option, which has been
22
26
  replaced with `serializer: Marshal` to support pluggable serialization
@@ -27,14 +31,15 @@ class Redis
27
31
  )
28
32
  end
29
33
 
30
- @serializer = options.key?(:serializer) ? options[:serializer] : Marshal
34
+ @serializer = orig_options.key?(:serializer) ? orig_options.delete(:serializer) : Marshal
31
35
 
32
- unless options[:marshalling].nil?
33
- @serializer = options[:marshalling] ? Marshal : nil
36
+ unless orig_options[:marshalling].nil?
37
+ # `marshalling` only used here, might not be supported in `super`
38
+ @serializer = orig_options.delete(:marshalling) ? Marshal : nil
34
39
  end
35
40
 
36
- _extend_marshalling options
37
- _extend_namespace options
41
+ _extend_marshalling
42
+ _extend_namespace orig_options
38
43
  end
39
44
 
40
45
  def reconnect
@@ -56,7 +61,19 @@ class Redis
56
61
  end
57
62
 
58
63
  private
59
- def _extend_marshalling(options)
64
+ def _remove_unsupported_options(options)
65
+ return unless self.class.redis_client_defined?
66
+
67
+ # Unsupported keywords should be removed to avoid errors
68
+ # https://github.com/redis-rb/redis-client/blob/v0.13.0/lib/redis_client/config.rb#L21
69
+ options.delete(:raw)
70
+ options.delete(:serializer)
71
+ options.delete(:marshalling)
72
+ options.delete(:namespace)
73
+ options.delete(:scheme)
74
+ end
75
+
76
+ def _extend_marshalling
60
77
  extend Serialization unless @serializer.nil?
61
78
  end
62
79
 
data/redis-store.gemspec CHANGED
@@ -16,11 +16,11 @@ Gem::Specification.new do |s|
16
16
  s.require_paths = ["lib"]
17
17
  s.license = 'MIT'
18
18
 
19
- s.add_dependency 'redis', '>= 4', '< 5'
19
+ s.add_dependency 'redis', '>= 4', '< 6'
20
20
 
21
21
  s.add_development_dependency 'rake', '>= 12.3.3'
22
22
  s.add_development_dependency 'bundler'
23
- s.add_development_dependency 'mocha', '~> 0.14.0'
23
+ s.add_development_dependency 'mocha', '~> 2.1.0'
24
24
  s.add_development_dependency 'minitest', '~> 5'
25
25
  s.add_development_dependency 'git', '~> 1.2'
26
26
  s.add_development_dependency 'pry-nav', '~> 0.2.4'
@@ -17,9 +17,9 @@ describe "Redis::DistributedStore" do
17
17
 
18
18
  it "accepts connection params" do
19
19
  dmr = Redis::DistributedStore.new [ :host => "localhost", :port => "6380", :db => "1" ]
20
- dmr.ring.nodes.size == 1
20
+ _(dmr.ring.nodes.size).must_equal(1)
21
21
  mr = dmr.ring.nodes.first
22
- mr.to_s.must_equal("Redis Client connected to localhost:6380 against DB 1")
22
+ _(mr.to_s).must_equal("Redis Client connected to localhost:6380 against DB 1")
23
23
  end
24
24
 
25
25
  it "forces reconnection" do
@@ -32,11 +32,11 @@ describe "Redis::DistributedStore" do
32
32
 
33
33
  it "sets an object" do
34
34
  @dmr.set "rabbit", @white_rabbit
35
- @dmr.get("rabbit").must_equal(@white_rabbit)
35
+ _(@dmr.get("rabbit")).must_equal(@white_rabbit)
36
36
  end
37
37
 
38
38
  it "gets an object" do
39
- @dmr.get("rabbit").must_equal(@rabbit)
39
+ _(@dmr.get("rabbit")).must_equal(@rabbit)
40
40
  end
41
41
 
42
42
  it "mget" do
@@ -44,9 +44,9 @@ describe "Redis::DistributedStore" do
44
44
  begin
45
45
  @dmr.mget "rabbit", "rabbit2" do |rabbits|
46
46
  rabbit, rabbit2 = rabbits
47
- rabbits.length.must_equal(2)
48
- rabbit.must_equal(@rabbit)
49
- rabbit2.must_equal(@white_rabbit)
47
+ _(rabbits.length).must_equal(2)
48
+ _(rabbit).must_equal(@rabbit)
49
+ _(rabbit2).must_equal(@white_rabbit)
50
50
  end
51
51
  rescue Redis::Distributed::CannotDistribute
52
52
  # Not supported on redis-rb < 4, and hence Ruby < 2.2.
@@ -57,9 +57,9 @@ describe "Redis::DistributedStore" do
57
57
  @dmr.set "rabbit2", @white_rabbit
58
58
  begin
59
59
  result = @dmr.mapped_mget("rabbit", "rabbit2")
60
- result.keys.must_equal %w[ rabbit rabbit2 ]
61
- result["rabbit"].must_equal @rabbit
62
- result["rabbit2"].must_equal @white_rabbit
60
+ _(result.keys).must_equal %w[ rabbit rabbit2 ]
61
+ _(result["rabbit"]).must_equal @rabbit
62
+ _(result["rabbit2"]).must_equal @white_rabbit
63
63
  rescue Redis::Distributed::CannotDistribute
64
64
  # Not supported on redis-rb < 4, and hence Ruby < 2.2.
65
65
  end
@@ -70,7 +70,7 @@ describe "Redis::DistributedStore" do
70
70
  { :host => "localhost", :port => "6380", :db => 0 },
71
71
  { :host => "localhost", :port => "6381", :db => 0 }
72
72
  ], replicas: 1024
73
- dmr.ring.replicas.must_equal 1024
73
+ _(dmr.ring.replicas).must_equal 1024
74
74
  end
75
75
 
76
76
  it "uses a custom ring object" do
@@ -79,8 +79,8 @@ describe "Redis::DistributedStore" do
79
79
  { :host => "localhost", :port => "6380", :db => 0 },
80
80
  { :host => "localhost", :port => "6381", :db => 0 }
81
81
  ], ring: my_ring
82
- dmr.ring.must_equal my_ring
83
- dmr.ring.nodes.length.must_equal 2
82
+ _(dmr.ring).must_equal my_ring
83
+ _(dmr.ring.nodes.length).must_equal 2
84
84
  end
85
85
 
86
86
  describe '#redis_version' do
@@ -108,4 +108,4 @@ describe "Redis::DistributedStore" do
108
108
  @dmr.get "rabbit"
109
109
  end
110
110
  end
111
- end
111
+ end unless ENV['CI']