redis-store 1.6.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/auto-assign-issues.yml +2 -0
- data/.travis.yml +24 -22
- data/CODEOWNERS +1 -0
- data/lib/redis/store/namespace.rb +27 -0
- data/lib/redis/store/ttl.rb +1 -1
- data/lib/redis/store/version.rb +1 -1
- data/redis-store.gemspec +2 -2
- data/test/redis/store/namespace_test.rb +26 -0
- data/test/redis/store/ttl_test.rb +19 -0
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48f4ede21caf667a2743c9827827292d2aa83be7
|
4
|
+
data.tar.gz: 33ba8ec50c9e700474a71b7a8d00be54d35dc093
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14df20e6fb35c1d6af7958b9fd2879087d98a578e8fb0c576f4884b69615c4af68b987a446ef8de7fb52ed51de76717b90cb2e2a290341f8dc7e29b3381a8ea7
|
7
|
+
data.tar.gz: cbc94b8900774f3723b6cf03b6bd4e0be1931d1620ea9d97f04b52e2d8c92f813a1c7a40fd66dda808358f68db6eaf8b735950c9f1512aed0cbd0593031ef252
|
data/.travis.yml
CHANGED
@@ -4,38 +4,40 @@ cache: bundler
|
|
4
4
|
notifications:
|
5
5
|
webhooks: https://www.travisbuddy.com
|
6
6
|
on_success: never
|
7
|
-
|
8
7
|
before_install:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# 1.9.3 has Bundler 1.7.6 with the "undefined method `spec' for nil" bug
|
13
|
-
- gem install bundler
|
14
|
-
|
8
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
|
9
|
+
> ./cc-test-reporter
|
10
|
+
- chmod +x ./cc-test-reporter
|
15
11
|
rvm:
|
16
12
|
- 2.1
|
17
13
|
- 2.2
|
18
14
|
- 2.3
|
19
15
|
- 2.4
|
16
|
+
- 2.5
|
17
|
+
- 2.6
|
20
18
|
- ruby-head
|
21
19
|
- jruby-head
|
22
|
-
|
23
20
|
gemfile:
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
before_script: ./cc-test-reporter before-build
|
28
|
-
|
29
|
-
# Pipe the coverage data to Code Climate if tests pass
|
21
|
+
- gemfiles/redis_4_x.gemfile
|
22
|
+
before_script: "./cc-test-reporter before-build"
|
30
23
|
after_script:
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
24
|
+
- "./cc-test-reporter after-build --exit-code $EXIT_CODE"
|
25
|
+
- "./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.json"
|
26
|
+
- if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then ./cc-test-reporter upload-coverage; fi
|
35
27
|
matrix:
|
36
28
|
allow_failures:
|
37
|
-
|
38
|
-
|
29
|
+
- rvm: jruby-head
|
30
|
+
- rvm: ruby-head
|
39
31
|
exclude:
|
40
|
-
|
41
|
-
|
32
|
+
- rvm: 2.1
|
33
|
+
gemfile: gemfiles/redis_4_x.gemfile
|
34
|
+
- rvm: 2.2
|
35
|
+
gemfile: gemfiles/redis_4_x.gemfile
|
36
|
+
deploy:
|
37
|
+
provider: rubygems
|
38
|
+
api_key:
|
39
|
+
secure: vhwP2VNfVYgppPNis7asqMnWuIcURr2e99uhYeHS4Sc+hIozu2QzAAekDrVpEDpeaEubtmTi19UcV4dZbDrQ0M+buE8LJEpItz73yK++J75Rzyh/bsGnWTy2FIvedLrH+jBNf28I9p8XNWkQxVaTc/r/v6BX3mmyV/jVoTBz9es=
|
40
|
+
gem: redis-store
|
41
|
+
on:
|
42
|
+
tags: true
|
43
|
+
repo: redis-store/redis-store
|
data/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @tubbo
|
@@ -39,10 +39,25 @@ class Redis
|
|
39
39
|
namespace(pattern) { |p| super(p).map { |key| strip_namespace(key) } }
|
40
40
|
end
|
41
41
|
|
42
|
+
def scan(cursor, options = {})
|
43
|
+
if options[:match]
|
44
|
+
namespace(options[:match]) do |pattern|
|
45
|
+
cursor, keys = super(cursor, options.merge(match: pattern))
|
46
|
+
[ cursor, keys.map{|key| strip_namespace(key) } ]
|
47
|
+
end
|
48
|
+
else
|
49
|
+
super(cursor, options)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
42
53
|
def del(*keys)
|
43
54
|
super(*keys.map { |key| interpolate(key) }) if keys.any?
|
44
55
|
end
|
45
56
|
|
57
|
+
def unlink(*keys)
|
58
|
+
super(*keys.map { |key| interpolate(key) }) if keys.any?
|
59
|
+
end
|
60
|
+
|
46
61
|
def watch(*keys)
|
47
62
|
super(*keys.map { |key| interpolate(key) }) if keys.any?
|
48
63
|
end
|
@@ -59,6 +74,18 @@ class Redis
|
|
59
74
|
end
|
60
75
|
end
|
61
76
|
|
77
|
+
def hgetall(key)
|
78
|
+
namespace(key) { |k| super(k) }
|
79
|
+
end
|
80
|
+
|
81
|
+
def hsetnx(key, field, val)
|
82
|
+
namespace(key) { |k| super(k, field, val) }
|
83
|
+
end
|
84
|
+
|
85
|
+
def hset(key, field, val)
|
86
|
+
namespace(key) { |k| super(k, field, val) }
|
87
|
+
end
|
88
|
+
|
62
89
|
def expire(key, ttl)
|
63
90
|
namespace(key) { |k| super(k, ttl) }
|
64
91
|
end
|
data/lib/redis/store/ttl.rb
CHANGED
data/lib/redis/store/version.rb
CHANGED
data/redis-store.gemspec
CHANGED
@@ -20,10 +20,10 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
s.license = 'MIT'
|
22
22
|
|
23
|
-
s.add_dependency 'redis', '>=
|
23
|
+
s.add_dependency 'redis', '>= 4', '< 5'
|
24
24
|
|
25
25
|
s.add_development_dependency 'rake', '~> 10'
|
26
|
-
s.add_development_dependency 'bundler'
|
26
|
+
s.add_development_dependency 'bundler'
|
27
27
|
s.add_development_dependency 'mocha', '~> 0.14.0'
|
28
28
|
s.add_development_dependency 'minitest', '~> 5'
|
29
29
|
s.add_development_dependency 'git', '~> 1.2'
|
@@ -123,6 +123,17 @@ describe "Redis::Store::Namespace" do
|
|
123
123
|
store.keys("rabb*").must_equal [ "rabbit" ]
|
124
124
|
end
|
125
125
|
|
126
|
+
it "should namespace scan when a pattern is given" do
|
127
|
+
store.set "rabbit", @rabbit
|
128
|
+
cursor = "0"
|
129
|
+
keys = []
|
130
|
+
begin
|
131
|
+
cursor, matched_keys = store.scan(cursor, match: "rabb*")
|
132
|
+
keys = keys.concat(matched_keys) unless matched_keys.empty?
|
133
|
+
end until cursor == "0"
|
134
|
+
keys.must_equal [ "rabbit" ]
|
135
|
+
end
|
136
|
+
|
126
137
|
it "should namespace exists" do
|
127
138
|
client.expects(:call).with([:exists, "#{@namespace}:rabbit"])
|
128
139
|
store.exists "rabbit"
|
@@ -182,5 +193,20 @@ describe "Redis::Store::Namespace" do
|
|
182
193
|
store.flushdb
|
183
194
|
end
|
184
195
|
end
|
196
|
+
|
197
|
+
it "should namespace hgetall" do
|
198
|
+
client.expects(:call).with([:hgetall, "#{@namespace}:rabbit"]).once
|
199
|
+
store.hgetall("rabbit")
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should namespace hsetnx" do
|
203
|
+
client.expects(:call).with([:hsetnx, "#{@namespace}:rabbit", "key", @rabbit])
|
204
|
+
store.hsetnx("rabbit", "key", @rabbit)
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should namespace hset" do
|
208
|
+
client.expects(:call).with([:hset, "#{@namespace}:rabbit", "key", @rabbit])
|
209
|
+
store.hset("rabbit", "key", @rabbit)
|
210
|
+
end
|
185
211
|
end
|
186
212
|
end
|
@@ -133,6 +133,25 @@ describe MockTtlStore do
|
|
133
133
|
redis.has_expire?(key, options[:expire_after]).must_equal true
|
134
134
|
end
|
135
135
|
end
|
136
|
+
|
137
|
+
describe 'using a redis cluster' do
|
138
|
+
let(:options) { { :expire_after => 3600, :cluster => %w[redis://127.0.0.1:6379/0] } }
|
139
|
+
|
140
|
+
it 'uses the redis pipelined feature to chain commands' do
|
141
|
+
redis.expects(:pipelined)
|
142
|
+
redis.setnx(key, mock_value, options)
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'must call setnx with key and value and set raw to true' do
|
146
|
+
redis.setnx(key, mock_value, options)
|
147
|
+
redis.has_setnx?(key, mock_value, :raw => true).must_equal true
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'must call expire' do
|
151
|
+
redis.setnx(key, mock_value, options)
|
152
|
+
redis.has_expire?(key, options[:expire_after]).must_equal true
|
153
|
+
end
|
154
|
+
end
|
136
155
|
end
|
137
156
|
end
|
138
157
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '5'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '4'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '5'
|
@@ -48,16 +48,16 @@ dependencies:
|
|
48
48
|
name: bundler
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "
|
51
|
+
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '0'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- - "
|
58
|
+
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: mocha
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,11 +179,13 @@ extensions: []
|
|
179
179
|
extra_rdoc_files: []
|
180
180
|
files:
|
181
181
|
- ".codeclimate.yml"
|
182
|
+
- ".github/auto-assign-issues.yml"
|
182
183
|
- ".gitignore"
|
183
184
|
- ".rubocop.yml"
|
184
185
|
- ".travis.yml"
|
185
186
|
- Appraisals
|
186
187
|
- CHANGELOG.md
|
188
|
+
- CODEOWNERS
|
187
189
|
- Gemfile
|
188
190
|
- MIT-LICENSE
|
189
191
|
- README.md
|