redis-store 1.6.0 → 1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/auto-assign-issues.yml +2 -0
- data/.github/release.yml +13 -0
- data/.github/workflows/ci.yml +62 -0
- data/.github/workflows/publish.yml +32 -0
- data/.rubocop.yml +5 -11
- data/Appraisals +13 -2
- data/CHANGELOG.md +59 -1
- data/CODEOWNERS +1 -0
- data/README.md +3 -3
- data/Rakefile +1 -1
- data/gemfiles/redis_4_0_x.gemfile +7 -0
- data/gemfiles/redis_4_1_x.gemfile +7 -0
- data/gemfiles/redis_4_6_x.gemfile +7 -0
- data/gemfiles/{redis_3_x.gemfile → redis_5_x.gemfile} +1 -1
- data/lib/redis/store/interface.rb +9 -1
- data/lib/redis/store/namespace.rb +109 -10
- data/lib/redis/store/ttl.rb +9 -4
- data/lib/redis/store/version.rb +1 -1
- data/redis-store.gemspec +3 -7
- data/test/redis/distributed_store_test.rb +13 -13
- data/test/redis/store/factory_test.rb +44 -44
- data/test/redis/store/namespace_test.rb +136 -18
- data/test/redis/store/redis_version_test.rb +6 -6
- data/test/redis/store/serialization_test.rb +46 -44
- data/test/redis/store/ttl_test.rb +17 -13
- data/test/redis/store/version_test.rb +1 -1
- data/test/redis/store_test.rb +7 -7
- metadata +25 -29
- data/.travis.yml +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7a70e9a1e720591e28f5abee4cbfff877503f808a9318143234579ea942dc073
|
4
|
+
data.tar.gz: 037aa5824d933374d37e0f922c8992034ed48d05bf00069be6040d52a6706b2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe1f61f58277a706a19100e85433bd7177b23b8245c6f1354cbe49abdcb2aa9abed9a3956686b074d5c9edb7006f5dbb8f8715d579f316832eecf711a656dab1
|
7
|
+
data.tar.gz: 22d18ed2621e2075d2e02a7f830d4ad2de45f834405f62650e9f41f19bff6b6d3a5017d1247fe0de893e5d3c21f71c3aed63f742c8823d05bef5cf6148c74c4d
|
data/.github/release.yml
ADDED
@@ -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,62 @@
|
|
1
|
+
name: CI
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches-ignore: [master]
|
5
|
+
tags-ignore: [v*]
|
6
|
+
concurrency:
|
7
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
8
|
+
cancel-in-progress: true
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
name: "test (ruby: ${{ matrix.ruby }}, redis.rb: ${{ matrix.redis }})"
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
continue-on-error: ${{ contains(matrix.ruby, 'head') }}
|
14
|
+
strategy:
|
15
|
+
fail-fast: false
|
16
|
+
matrix:
|
17
|
+
ruby:
|
18
|
+
- "2.7"
|
19
|
+
- "3.0"
|
20
|
+
- "3.1"
|
21
|
+
# - 'head'
|
22
|
+
- "jruby"
|
23
|
+
# - 'jruby-head'
|
24
|
+
- "truffleruby"
|
25
|
+
# - 'truffleruby-head'
|
26
|
+
redis:
|
27
|
+
- 4_0_x
|
28
|
+
- 4_1_x
|
29
|
+
- 4_x
|
30
|
+
env:
|
31
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/redis_${{ matrix.redis }}.gemfile
|
32
|
+
services:
|
33
|
+
redis:
|
34
|
+
image: redis
|
35
|
+
ports:
|
36
|
+
- 6379:6379
|
37
|
+
distributed1:
|
38
|
+
image: redis
|
39
|
+
ports:
|
40
|
+
- 6380:6380
|
41
|
+
distributed2:
|
42
|
+
image: redis
|
43
|
+
ports:
|
44
|
+
- 6381:6381
|
45
|
+
steps:
|
46
|
+
- uses: actions/checkout@v3
|
47
|
+
- uses: ruby/setup-ruby@v1
|
48
|
+
with:
|
49
|
+
ruby-version: ${{ matrix.ruby }}
|
50
|
+
bundler-cache: true
|
51
|
+
- run: bundle exec rake
|
52
|
+
lint:
|
53
|
+
runs-on: ubuntu-latest
|
54
|
+
steps:
|
55
|
+
- uses: actions/checkout@v3
|
56
|
+
with:
|
57
|
+
fetch-depth: 0
|
58
|
+
- uses: ruby/setup-ruby@v1
|
59
|
+
with:
|
60
|
+
ruby-version: 3.1
|
61
|
+
bundler-cache: true
|
62
|
+
- 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
|
+
bundler-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/.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
|
-
-
|
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:
|
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/
|
96
|
+
Layout/IndentationStyle:
|
103
97
|
Enabled: true
|
104
98
|
|
105
99
|
# Blank lines should not have any spaces.
|
106
|
-
Layout/
|
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/
|
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,8 +1,19 @@
|
|
1
|
+
appraise "redis_4_0_x" do
|
2
|
+
gem "redis", "~> 4.0.0"
|
3
|
+
end
|
4
|
+
|
5
|
+
appraise "redis_4_1_x" do
|
6
|
+
gem "redis", "~> 4.1.0"
|
7
|
+
end
|
1
8
|
|
2
|
-
appraise "
|
3
|
-
gem "redis", "~>
|
9
|
+
appraise "redis_4_6_x" do
|
10
|
+
gem "redis", "~> 4.6.0"
|
4
11
|
end
|
5
12
|
|
6
13
|
appraise "redis_4_x" do
|
7
14
|
gem "redis", "~> 4.0"
|
8
15
|
end
|
16
|
+
|
17
|
+
appraise "redis_5_x" do
|
18
|
+
gem "redis", "~> 5.0"
|
19
|
+
end
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,63 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.9.0
|
4
|
+
|
5
|
+
Breaking Changes
|
6
|
+
|
7
|
+
* As a factor of updates for Redis v4.2.x, support for Ruby 2.1 and 2.2
|
8
|
+
has been dropped. These Ruby versions are end-of-life anyway.
|
9
|
+
|
10
|
+
Fixed
|
11
|
+
|
12
|
+
* [Compatibility with Redis client v4.2.x](https://github.com/redis-store/redis-store/pull/333)
|
13
|
+
|
14
|
+
Added
|
15
|
+
|
16
|
+
* [Support for edge Ruby's keyword arguments](https://github.com/redis-store/redis-store/pull/334)
|
17
|
+
|
18
|
+
## 1.8.2
|
19
|
+
|
20
|
+
Breaking Changes
|
21
|
+
|
22
|
+
* None
|
23
|
+
|
24
|
+
Added
|
25
|
+
|
26
|
+
* [Add namespace to zincrby and zscore](https://github.com/redis-store/redis-store/pull/323)
|
27
|
+
* [Add namespace to zadd and zrem](https://github.com/redis-store/redis-store/pull/326)
|
28
|
+
|
29
|
+
Fixed
|
30
|
+
|
31
|
+
* None
|
32
|
+
|
33
|
+
## 1.8.1
|
34
|
+
|
35
|
+
Breaking Changes
|
36
|
+
|
37
|
+
* None
|
38
|
+
|
39
|
+
Added
|
40
|
+
|
41
|
+
* None
|
42
|
+
|
43
|
+
Fixed
|
44
|
+
|
45
|
+
* [Add namespace to remaining hash methods](https://github.com/redis-store/redis-store/pull/321)
|
46
|
+
|
47
|
+
## 1.8.0
|
48
|
+
|
49
|
+
Breaking Changes
|
50
|
+
|
51
|
+
* None
|
52
|
+
|
53
|
+
Added
|
54
|
+
|
55
|
+
* [Redis Cluster Support](https://github.com/redis-store/redis-store/pull/318)
|
56
|
+
|
57
|
+
Fixed
|
58
|
+
|
59
|
+
* None
|
60
|
+
|
3
61
|
## 1.6.0
|
4
62
|
|
5
63
|
Breaking Changes
|
@@ -59,7 +117,7 @@ Added
|
|
59
117
|
|
60
118
|
Fixed
|
61
119
|
|
62
|
-
* Conventional `Marshal.dump` usage allowing potential security vulnerability (CVE-2017-1000248)
|
120
|
+
* Conventional `Marshal.dump` usage allowing potential security vulnerability (CVE-2017-1000248)
|
63
121
|
|
64
122
|
## 1.3.0
|
65
123
|
|
data/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @tubbo
|
data/README.md
CHANGED
@@ -45,9 +45,9 @@ s.add_dependency 'redis-store', '>= 1.4', '< 2'
|
|
45
45
|
|
46
46
|
## Status
|
47
47
|
|
48
|
-
[![Gem Version](https://badge.fury.io/rb/redis-store.
|
49
|
-
[![Build Status](https://secure.travis-ci.org/redis-store/redis-store.
|
50
|
-
[![Code Climate](https://codeclimate.com/github/redis-store/redis-store.
|
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)
|
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
|
53
53
|
|
data/Rakefile
CHANGED
@@ -5,8 +5,16 @@ class Redis
|
|
5
5
|
super(key)
|
6
6
|
end
|
7
7
|
|
8
|
+
REDIS_SET_OPTIONS = %i(ex px nx xx keepttl).freeze
|
9
|
+
private_constant :REDIS_SET_OPTIONS
|
10
|
+
|
8
11
|
def set(key, value, options = nil)
|
9
|
-
|
12
|
+
if options && REDIS_SET_OPTIONS.any? { |k| options.key?(k) }
|
13
|
+
kwargs = REDIS_SET_OPTIONS.each_with_object({}) { |key, h| h[key] = options[key] if options.key?(key) }
|
14
|
+
super(key, value, **kwargs)
|
15
|
+
else
|
16
|
+
super(key, value)
|
17
|
+
end
|
10
18
|
end
|
11
19
|
|
12
20
|
def setnx(key, value, options = nil)
|
@@ -3,28 +3,32 @@ class Redis
|
|
3
3
|
module Namespace
|
4
4
|
FLUSHDB_BATCH_SIZE = 1000
|
5
5
|
|
6
|
-
def set(key,
|
7
|
-
namespace(key) { |k| super(k,
|
6
|
+
def set(key, *args)
|
7
|
+
namespace(key) { |k| super(k, *args) }
|
8
8
|
end
|
9
9
|
|
10
|
-
def setex(key,
|
11
|
-
namespace(key) { |k| super(k,
|
10
|
+
def setex(key, *args)
|
11
|
+
namespace(key) { |k| super(k, *args) }
|
12
12
|
end
|
13
13
|
|
14
|
-
def setnx(key,
|
15
|
-
namespace(key) { |k| super(k,
|
14
|
+
def setnx(key, *args)
|
15
|
+
namespace(key) { |k| super(k, *args) }
|
16
16
|
end
|
17
17
|
|
18
18
|
def ttl(key, options = nil)
|
19
19
|
namespace(key) { |k| super(k) }
|
20
20
|
end
|
21
21
|
|
22
|
-
def get(key,
|
23
|
-
namespace(key) { |k| super(k,
|
22
|
+
def get(key, *args)
|
23
|
+
namespace(key) { |k| super(k, *args) }
|
24
24
|
end
|
25
25
|
|
26
|
-
def exists(
|
27
|
-
|
26
|
+
def exists(*keys)
|
27
|
+
super(*keys.map { |key| interpolate(key) })
|
28
|
+
end
|
29
|
+
|
30
|
+
def exists?(*keys)
|
31
|
+
super(*keys.map { |key| interpolate(key) })
|
28
32
|
end
|
29
33
|
|
30
34
|
def incrby(key, increment)
|
@@ -39,10 +43,25 @@ class Redis
|
|
39
43
|
namespace(pattern) { |p| super(p).map { |key| strip_namespace(key) } }
|
40
44
|
end
|
41
45
|
|
46
|
+
def scan(cursor, match: nil, **kwargs)
|
47
|
+
if match
|
48
|
+
namespace(match) do |pattern|
|
49
|
+
cursor, keys = super(cursor, match: pattern, **kwargs)
|
50
|
+
[ cursor, keys.map { |key| strip_namespace(key) } ]
|
51
|
+
end
|
52
|
+
else
|
53
|
+
super(cursor, **kwargs)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
42
57
|
def del(*keys)
|
43
58
|
super(*keys.map { |key| interpolate(key) }) if keys.any?
|
44
59
|
end
|
45
60
|
|
61
|
+
def unlink(*keys)
|
62
|
+
super(*keys.map { |key| interpolate(key) }) if keys.any?
|
63
|
+
end
|
64
|
+
|
46
65
|
def watch(*keys)
|
47
66
|
super(*keys.map { |key| interpolate(key) }) if keys.any?
|
48
67
|
end
|
@@ -63,6 +82,86 @@ class Redis
|
|
63
82
|
namespace(key) { |k| super(k, ttl) }
|
64
83
|
end
|
65
84
|
|
85
|
+
def hdel(key, *fields)
|
86
|
+
namespace(key) { |k| super(k, *fields) }
|
87
|
+
end
|
88
|
+
|
89
|
+
def hget(key, field)
|
90
|
+
namespace(key) { |k| super(k, field) }
|
91
|
+
end
|
92
|
+
|
93
|
+
def hgetall(key)
|
94
|
+
namespace(key) { |k| super(k) }
|
95
|
+
end
|
96
|
+
|
97
|
+
def hexists(key, field)
|
98
|
+
namespace(key) { |k| super(k, field) }
|
99
|
+
end
|
100
|
+
|
101
|
+
def hincrby(key, field, increment)
|
102
|
+
namespace(key) { |k| super(k, field, increment) }
|
103
|
+
end
|
104
|
+
|
105
|
+
def hincrbyfloat(key, field, increment)
|
106
|
+
namespace(key) { |k| super(k, field, increment) }
|
107
|
+
end
|
108
|
+
|
109
|
+
def hkeys(key)
|
110
|
+
namespace(key) { |k| super(k) }
|
111
|
+
end
|
112
|
+
|
113
|
+
def hlen(key)
|
114
|
+
namespace(key) { |k| super(k) }
|
115
|
+
end
|
116
|
+
|
117
|
+
def hmget(key, *fields, &blk)
|
118
|
+
namespace(key) { |k| super(k, *fields, &blk) }
|
119
|
+
end
|
120
|
+
|
121
|
+
def hmset(key, *attrs)
|
122
|
+
namespace(key) { |k| super(k, *attrs) }
|
123
|
+
end
|
124
|
+
|
125
|
+
def hset(key, *args)
|
126
|
+
namespace(key) { |k| super(k, *args) }
|
127
|
+
end
|
128
|
+
|
129
|
+
def hsetnx(key, field, val)
|
130
|
+
namespace(key) { |k| super(k, field, val) }
|
131
|
+
end
|
132
|
+
|
133
|
+
def hvals(key)
|
134
|
+
namespace(key) { |k| super(k) }
|
135
|
+
end
|
136
|
+
|
137
|
+
def hscan(key, *args)
|
138
|
+
namespace(key) { |k| super(k, *args) }
|
139
|
+
end
|
140
|
+
|
141
|
+
def hscan_each(key, *args)
|
142
|
+
namespace(key) { |k| super(k, *args) }
|
143
|
+
end
|
144
|
+
|
145
|
+
def zincrby(key, increment, member)
|
146
|
+
namespace(key) { |k| super(k, increment, member) }
|
147
|
+
end
|
148
|
+
|
149
|
+
def zscore(key, member)
|
150
|
+
namespace(key) { |k| super(k, member) }
|
151
|
+
end
|
152
|
+
|
153
|
+
def zadd(key, *args)
|
154
|
+
namespace(key) { |k| super(k, *args) }
|
155
|
+
end
|
156
|
+
|
157
|
+
def zrem(key, member)
|
158
|
+
namespace(key) { |k| super(k, member) }
|
159
|
+
end
|
160
|
+
|
161
|
+
if respond_to?(:ruby2_keywords, true)
|
162
|
+
ruby2_keywords :set, :setex, :setnx, :hscan, :hscan_each
|
163
|
+
end
|
164
|
+
|
66
165
|
def to_s
|
67
166
|
if namespace_str
|
68
167
|
"#{super} with namespace #{namespace_str}"
|
data/lib/redis/store/ttl.rb
CHANGED
@@ -19,9 +19,14 @@ class Redis
|
|
19
19
|
|
20
20
|
protected
|
21
21
|
def setnx_with_expire(key, value, ttl, options = {})
|
22
|
-
with_multi_or_pipelined(options) do
|
23
|
-
|
24
|
-
|
22
|
+
with_multi_or_pipelined(options) do |transaction|
|
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
|
|
@@ -34,7 +39,7 @@ class Redis
|
|
34
39
|
end
|
35
40
|
|
36
41
|
def with_multi_or_pipelined(options, &block)
|
37
|
-
return pipelined(&block) if options[:avoid_multi_commands]
|
42
|
+
return pipelined(&block) if options.key?(:cluster) || options[:avoid_multi_commands]
|
38
43
|
multi(&block)
|
39
44
|
end
|
40
45
|
end
|
data/lib/redis/store/version.rb
CHANGED
data/redis-store.gemspec
CHANGED
@@ -12,18 +12,14 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = 'Redis stores for Ruby frameworks'
|
13
13
|
s.description = 'Namespaced Rack::Session, Rack::Cache, I18n and cache Redis stores for Ruby web frameworks.'
|
14
14
|
|
15
|
-
s.rubyforge_project = 'redis-store'
|
16
|
-
|
17
15
|
s.files = `git ls-files`.split("\n")
|
18
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
20
16
|
s.require_paths = ["lib"]
|
21
17
|
s.license = 'MIT'
|
22
18
|
|
23
|
-
s.add_dependency 'redis', '>=
|
19
|
+
s.add_dependency 'redis', '>= 4', '< 6'
|
24
20
|
|
25
|
-
s.add_development_dependency 'rake', '
|
26
|
-
s.add_development_dependency 'bundler'
|
21
|
+
s.add_development_dependency 'rake', '>= 12.3.3'
|
22
|
+
s.add_development_dependency 'bundler'
|
27
23
|
s.add_development_dependency 'mocha', '~> 0.14.0'
|
28
24
|
s.add_development_dependency 'minitest', '~> 5'
|
29
25
|
s.add_development_dependency 'git', '~> 1.2'
|
@@ -19,7 +19,7 @@ describe "Redis::DistributedStore" do
|
|
19
19
|
dmr = Redis::DistributedStore.new [ :host => "localhost", :port => "6380", :db => "1" ]
|
20
20
|
dmr.ring.nodes.size == 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']
|