redis-namespace 1.5.2 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +85 -17
- data/lib/redis/namespace.rb +95 -37
- data/lib/redis/namespace/version.rb +1 -1
- data/spec/deprecation_spec.rb +32 -0
- data/spec/redis_spec.rb +19 -3
- metadata +20 -32
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d8a331998a5b4c5b9f5f323da912dc2e4555a2db
|
4
|
+
data.tar.gz: da08789df8269adf261ff47f7c1da894718ddc88
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 68d3325257b3c5a9ba0a7e461c39d30ce9de639304e8926e809e5f51256c5da41a8cdb2f29a5c2cd5c700032dc6d4e5b42be3e29327bcdaf0439c93f4db03f0a
|
7
|
+
data.tar.gz: cffdb70935cade3a38e66e46a71ad9082afb074ebbbc05627113b6504e5b6337ec8c917734eeaf871e6dea271e9483bdfa11b22bdf1b772eab04e0f973fc3bdc
|
data/README.md
CHANGED
@@ -1,38 +1,106 @@
|
|
1
1
|
redis-namespace
|
2
|
-
|
2
|
+
===============
|
3
3
|
|
4
|
-
|
4
|
+
Redis::Namespace provides an interface to a namespaced subset of your [redis][] keyspace (e.g., keys with a common beginning), and requires the [redis-rb][] gem.
|
5
5
|
|
6
|
-
|
6
|
+
~~~ irb
|
7
|
+
require 'redis-namespace'
|
8
|
+
# => true
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
redis_connection = Redis.new
|
11
|
+
# => #<Redis client v3.1.0 for redis://127.0.0.1:6379/0>
|
12
|
+
namespaced_redis = Redis::Namespace.new(:ns, :redis => redis_connection)
|
13
|
+
# => #<Redis::Namespace v1.5.0 with client v3.1.0 for redis://127.0.0.1:6379/0/ns>
|
12
14
|
|
13
|
-
|
15
|
+
namespaced_redis.set('foo', 'bar') # redis_connection.set('ns:foo', 'bar')
|
16
|
+
# => "OK"
|
14
17
|
|
15
|
-
|
18
|
+
# Redis::Namespace automatically prepended our namespace to the key
|
19
|
+
# before sending it to our redis client.
|
16
20
|
|
17
|
-
|
21
|
+
namespaced_redis.get('foo')
|
22
|
+
# => "bar"
|
23
|
+
redis_connection.get('ns:foo')
|
24
|
+
# => "bar"
|
18
25
|
|
26
|
+
namespaced_redis.del('foo')
|
27
|
+
# => 1
|
28
|
+
namespaced_redis.get('foo')
|
29
|
+
# => nil
|
30
|
+
redis_connection.get('ns:foo')
|
31
|
+
# => nil
|
32
|
+
~~~
|
19
33
|
|
20
34
|
Installation
|
21
35
|
============
|
22
36
|
|
37
|
+
Redis::Namespace is packaged as the redis-namespace gem, and hosted on rubygems.org.
|
38
|
+
|
39
|
+
From the command line:
|
40
|
+
|
23
41
|
$ gem install redis-namespace
|
24
42
|
|
43
|
+
Or in your Gemfile:
|
25
44
|
|
45
|
+
~~~ ruby
|
46
|
+
gem 'redis-namespace'
|
47
|
+
~~~
|
26
48
|
|
27
|
-
|
49
|
+
Caveats
|
28
50
|
=======
|
29
51
|
|
30
|
-
|
31
|
-
|
52
|
+
`Redis::Namespace` provides a namespaced interface to `Redis` by keeping an internal registry of the method signatures in `Redis` provided by the redis-rb gem;
|
53
|
+
we keep track of which arguments need the namespace added, and which return values need the namespace removed.
|
54
|
+
|
55
|
+
Blind Passthrough
|
56
|
+
-----------------
|
57
|
+
If your version of this gem doesn't know about a particular command, it can't namespace it.
|
58
|
+
Historically, this has meant that Redis::Namespace blindly passes unknown commands on to the underlying redis connection without modification which can lead to surprising effects.
|
59
|
+
|
60
|
+
As of v1.5.0, blind passthrough has been deprecated, and the functionality will be removed entirely in 2.0.
|
61
|
+
|
62
|
+
If you come across a command that is not yet supported, please open an issue on the [issue tracker][] or submit a pull-request.
|
63
|
+
|
64
|
+
Administrative Commands
|
65
|
+
-----------------------
|
66
|
+
The effects of some redis commands cannot be limited to a particular namespace (e.g., `FLUSHALL`, which literally truncates all databases in your redis server, regardless of keyspace).
|
67
|
+
Historically, this has meant that Redis::Namespace intentionally passes administrative commands on to the underlying redis connection without modification, which can lead to surprising effects.
|
68
|
+
|
69
|
+
As of v1.6.0, the direct use of administrative commands has been deprecated, and the functionality will be removed entirely in 2.0;
|
70
|
+
while such commands are often useful for testing or administration, their meaning is inherently hidden when placed behind an interface that implies it will namespace everything.
|
71
|
+
|
72
|
+
The prefered way to send an administrative command is on the redis connection
|
73
|
+
itself, which is publicly exposed as `Redis::Namespace#redis`:
|
74
|
+
|
75
|
+
~~~ ruby
|
76
|
+
namespaced.redis.flushall()
|
77
|
+
# => "OK"
|
78
|
+
~~~
|
79
|
+
|
80
|
+
2.x Planned Breaking Changes
|
81
|
+
============================
|
82
|
+
|
83
|
+
As mentioned above, 2.0 will remove blind passthrough and the administrative command passthrough.
|
84
|
+
By default in 1.5+, deprecation warnings are present and enabled;
|
85
|
+
they can be silenced by initializing `Redis::Namespace` with `warnings: false` or by setting the `REDIS_NAMESPACE_QUIET` environment variable.
|
86
|
+
|
87
|
+
Early opt-in
|
88
|
+
------------
|
89
|
+
|
90
|
+
To enable testing against the 2.x interface before its release, in addition to deprecation warnings, early opt-in to these changes can be enabled by initializing `Redis::Namespace` with `deprecations: true` or by setting the `REDIS_NAMESPACE_DEPRECATIONS` environment variable.
|
91
|
+
This should only be done once all warnings have been addressed.
|
92
|
+
|
93
|
+
Authors
|
94
|
+
=======
|
32
95
|
|
96
|
+
While there are many authors who have contributed to this project, the following have done so on an ongoing basis with at least 5 commits:
|
33
97
|
|
34
|
-
|
35
|
-
|
98
|
+
- Chris Wanstrath (@defunkt)
|
99
|
+
- Ryan Biesemeyer (@yaauie)
|
100
|
+
- Steve Klabnik (@steveklabnik)
|
101
|
+
- Terence Lee (@hone)
|
102
|
+
- Eoin Coffey (@ecoffey)
|
36
103
|
|
37
|
-
|
38
|
-
|
104
|
+
[redis]: http://redis.io
|
105
|
+
[redis-rb]: https://github.com/redis/redis-rb
|
106
|
+
[issue tracker]: https://github.com/resque/redis-namespace/issues
|
data/lib/redis/namespace.rb
CHANGED
@@ -3,7 +3,7 @@ require 'redis/namespace/version'
|
|
3
3
|
|
4
4
|
class Redis
|
5
5
|
class Namespace
|
6
|
-
# The following
|
6
|
+
# The following tables define how input parameters and result
|
7
7
|
# values should be modified for the namespace.
|
8
8
|
#
|
9
9
|
# COMMANDS is a hash. Each key is the name of a command and each
|
@@ -53,34 +53,23 @@ class Redis
|
|
53
53
|
# :all
|
54
54
|
# Add the namespace to all elements returned, e.g.
|
55
55
|
# key1 key2 => namespace:key1 namespace:key2
|
56
|
-
|
57
|
-
"append" => [:first],
|
58
|
-
"auth" => [],
|
59
|
-
"bgrewriteaof" => [],
|
60
|
-
"bgsave" => [],
|
56
|
+
NAMESPACED_COMMANDS = {
|
57
|
+
"append" => [ :first ],
|
61
58
|
"bitcount" => [ :first ],
|
62
59
|
"bitop" => [ :exclude_first ],
|
63
60
|
"blpop" => [ :exclude_last, :first ],
|
64
61
|
"brpop" => [ :exclude_last, :first ],
|
65
62
|
"brpoplpush" => [ :exclude_last ],
|
66
|
-
"config" => [],
|
67
|
-
"dbsize" => [],
|
68
63
|
"debug" => [ :exclude_first ],
|
69
64
|
"decr" => [ :first ],
|
70
65
|
"decrby" => [ :first ],
|
71
66
|
"del" => [ :all ],
|
72
|
-
"discard" => [],
|
73
|
-
"disconnect!" => [],
|
74
67
|
"dump" => [ :first ],
|
75
|
-
"echo" => [],
|
76
68
|
"exists" => [ :first ],
|
77
69
|
"expire" => [ :first ],
|
78
70
|
"expireat" => [ :first ],
|
79
71
|
"eval" => [ :eval_style ],
|
80
72
|
"evalsha" => [ :eval_style ],
|
81
|
-
"exec" => [],
|
82
|
-
"flushall" => [],
|
83
|
-
"flushdb" => [],
|
84
73
|
"get" => [ :first ],
|
85
74
|
"getbit" => [ :first ],
|
86
75
|
"getrange" => [ :first ],
|
@@ -103,9 +92,7 @@ class Redis
|
|
103
92
|
"incr" => [ :first ],
|
104
93
|
"incrby" => [ :first ],
|
105
94
|
"incrbyfloat" => [ :first ],
|
106
|
-
"info" => [],
|
107
95
|
"keys" => [ :first, :all ],
|
108
|
-
"lastsave" => [],
|
109
96
|
"lindex" => [ :first ],
|
110
97
|
"linsert" => [ :first ],
|
111
98
|
"llen" => [ :first ],
|
@@ -124,7 +111,6 @@ class Redis
|
|
124
111
|
"mget" => [ :all ],
|
125
112
|
"monitor" => [ :monitor ],
|
126
113
|
"move" => [ :first ],
|
127
|
-
"multi" => [],
|
128
114
|
"mset" => [ :alternate ],
|
129
115
|
"msetnx" => [ :alternate ],
|
130
116
|
"object" => [ :exclude_first ],
|
@@ -134,14 +120,11 @@ class Redis
|
|
134
120
|
"pfadd" => [ :first ],
|
135
121
|
"pfcount" => [ :all ],
|
136
122
|
"pfmerge" => [ :all ],
|
137
|
-
"ping" => [],
|
138
123
|
"psetex" => [ :first ],
|
139
124
|
"psubscribe" => [ :all ],
|
140
125
|
"pttl" => [ :first ],
|
141
126
|
"publish" => [ :first ],
|
142
127
|
"punsubscribe" => [ :all ],
|
143
|
-
"quit" => [],
|
144
|
-
"randomkey" => [],
|
145
128
|
"rename" => [ :all ],
|
146
129
|
"renamenx" => [ :all ],
|
147
130
|
"restore" => [ :first ],
|
@@ -150,24 +133,19 @@ class Redis
|
|
150
133
|
"rpush" => [ :first ],
|
151
134
|
"rpushx" => [ :first ],
|
152
135
|
"sadd" => [ :first ],
|
153
|
-
"save" => [],
|
154
136
|
"scard" => [ :first ],
|
155
137
|
"scan" => [ :scan_style, :second ],
|
156
138
|
"scan_each" => [ :scan_style, :all ],
|
157
|
-
"script" => [],
|
158
139
|
"sdiff" => [ :all ],
|
159
140
|
"sdiffstore" => [ :all ],
|
160
|
-
"select" => [],
|
161
141
|
"set" => [ :first ],
|
162
142
|
"setbit" => [ :first ],
|
163
143
|
"setex" => [ :first ],
|
164
144
|
"setnx" => [ :first ],
|
165
145
|
"setrange" => [ :first ],
|
166
|
-
"shutdown" => [],
|
167
146
|
"sinter" => [ :all ],
|
168
147
|
"sinterstore" => [ :all ],
|
169
148
|
"sismember" => [ :first ],
|
170
|
-
"slaveof" => [],
|
171
149
|
"smembers" => [ :first ],
|
172
150
|
"smove" => [ :exclude_last ],
|
173
151
|
"sort" => [ :sort ],
|
@@ -183,8 +161,6 @@ class Redis
|
|
183
161
|
"ttl" => [ :first ],
|
184
162
|
"type" => [ :first ],
|
185
163
|
"unsubscribe" => [ :all ],
|
186
|
-
"unwatch" => [ :all ],
|
187
|
-
"watch" => [ :all ],
|
188
164
|
"zadd" => [ :first ],
|
189
165
|
"zcard" => [ :first ],
|
190
166
|
"zcount" => [ :first ],
|
@@ -206,6 +182,48 @@ class Redis
|
|
206
182
|
"[]" => [ :first ],
|
207
183
|
"[]=" => [ :first ]
|
208
184
|
}
|
185
|
+
TRANSACTION_COMMANDS = {
|
186
|
+
"discard" => [],
|
187
|
+
"exec" => [],
|
188
|
+
"multi" => [],
|
189
|
+
"unwatch" => [ :all ],
|
190
|
+
"watch" => [ :all ],
|
191
|
+
}
|
192
|
+
HELPER_COMMANDS = {
|
193
|
+
"auth" => [],
|
194
|
+
"disconnect!" => [],
|
195
|
+
"echo" => [],
|
196
|
+
"ping" => [],
|
197
|
+
"time" => [],
|
198
|
+
}
|
199
|
+
ADMINISTRATIVE_COMMANDS = {
|
200
|
+
"bgrewriteaof" => [],
|
201
|
+
"bgsave" => [],
|
202
|
+
"config" => [],
|
203
|
+
"dbsize" => [],
|
204
|
+
"flushall" => [],
|
205
|
+
"flushdb" => [],
|
206
|
+
"info" => [],
|
207
|
+
"lastsave" => [],
|
208
|
+
"quit" => [],
|
209
|
+
"randomkey" => [],
|
210
|
+
"save" => [],
|
211
|
+
"script" => [],
|
212
|
+
"select" => [],
|
213
|
+
"shutdown" => [],
|
214
|
+
"slaveof" => [],
|
215
|
+
}
|
216
|
+
|
217
|
+
DEPRECATED_COMMANDS = [
|
218
|
+
ADMINISTRATIVE_COMMANDS
|
219
|
+
].compact.reduce(:merge)
|
220
|
+
|
221
|
+
COMMANDS = [
|
222
|
+
NAMESPACED_COMMANDS,
|
223
|
+
TRANSACTION_COMMANDS,
|
224
|
+
HELPER_COMMANDS,
|
225
|
+
ADMINISTRATIVE_COMMANDS,
|
226
|
+
].compact.reduce(:merge)
|
209
227
|
|
210
228
|
# Support 1.8.7 by providing a namespaced reference to Enumerable::Enumerator
|
211
229
|
Enumerator = Enumerable::Enumerator unless defined?(::Enumerator)
|
@@ -286,7 +304,20 @@ class Redis
|
|
286
304
|
def method_missing(command, *args, &block)
|
287
305
|
normalized_command = command.to_s.downcase
|
288
306
|
|
289
|
-
if
|
307
|
+
if ADMINISTRATIVE_COMMANDS.include?(normalized_command)
|
308
|
+
# administrative commands usage is deprecated and will be removed in 2.0
|
309
|
+
# redis-namespace cannot safely apply a namespace to their effects.
|
310
|
+
return super if deprecations?
|
311
|
+
if warning?
|
312
|
+
warn("Passing '#{normalized_command}' command to redis as is; " +
|
313
|
+
"administrative commands cannot be effectively namespaced " +
|
314
|
+
"and should be called on the redis connection directly; " +
|
315
|
+
"passthrough has been deprecated and will be removed in " +
|
316
|
+
"redis-namespace 2.0 (at #{call_site})"
|
317
|
+
)
|
318
|
+
end
|
319
|
+
call_with_namespace(command, *args, &block)
|
320
|
+
elsif COMMANDS.include?(normalized_command)
|
290
321
|
call_with_namespace(command, *args, &block)
|
291
322
|
elsif @redis.respond_to?(normalized_command) && !deprecations?
|
292
323
|
# blind passthrough is deprecated and will be removed in 2.0
|
@@ -294,7 +325,6 @@ class Redis
|
|
294
325
|
# Passing it to @redis as is, where redis-namespace shows
|
295
326
|
# a warning message if @warning is set.
|
296
327
|
if warning?
|
297
|
-
call_site = caller.reject { |l| l.start_with?(__FILE__) }.first
|
298
328
|
warn("Passing '#{command}' command to redis as is; blind " +
|
299
329
|
"passthrough has been deprecated and will be removed in " +
|
300
330
|
"redis-namespace 2.0 (at #{call_site})")
|
@@ -305,15 +335,24 @@ class Redis
|
|
305
335
|
end
|
306
336
|
end
|
307
337
|
|
338
|
+
def inspect
|
339
|
+
"<#{self.class.name} v#{VERSION} with client v#{Redis::VERSION} "\
|
340
|
+
"for #{@redis.id}/#{@namespace}>"
|
341
|
+
end
|
342
|
+
|
308
343
|
def respond_to_missing?(command, include_all=false)
|
309
|
-
|
344
|
+
normalized_command = command.to_s.downcase
|
310
345
|
|
311
|
-
|
312
|
-
|
313
|
-
|
346
|
+
case
|
347
|
+
when DEPRECATED_COMMANDS.include?(normalized_command)
|
348
|
+
!deprecations?
|
349
|
+
when COMMANDS.include?(normalized_command)
|
350
|
+
true
|
351
|
+
when !deprecations? && redis.respond_to?(command, include_all)
|
352
|
+
true
|
353
|
+
else
|
354
|
+
defined?(super) && super
|
314
355
|
end
|
315
|
-
|
316
|
-
defined?(super) && super
|
317
356
|
end
|
318
357
|
|
319
358
|
def call_with_namespace(command, *args, &block)
|
@@ -325,6 +364,9 @@ class Redis
|
|
325
364
|
|
326
365
|
(before, after) = handling
|
327
366
|
|
367
|
+
# Modify the local *args array in-place, no need to copy it.
|
368
|
+
args.map! {|arg| clone_args(arg)}
|
369
|
+
|
328
370
|
# Add the namespace to any parameters that are keys.
|
329
371
|
case before
|
330
372
|
when :first
|
@@ -410,6 +452,21 @@ class Redis
|
|
410
452
|
|
411
453
|
private
|
412
454
|
|
455
|
+
# Avoid modifying the caller's (pass-by-reference) arguments.
|
456
|
+
def clone_args(arg)
|
457
|
+
if arg.is_a?(Array)
|
458
|
+
arg.map {|sub_arg| clone_args(sub_arg)}
|
459
|
+
elsif arg.is_a?(Hash)
|
460
|
+
Hash[arg.map {|k, v| [clone_args(k), clone_args(v)]}]
|
461
|
+
else
|
462
|
+
arg # Some objects (e.g. symbol) can't be dup'd.
|
463
|
+
end
|
464
|
+
end
|
465
|
+
|
466
|
+
def call_site
|
467
|
+
caller.reject { |l| l.start_with?(__FILE__) }.first
|
468
|
+
end
|
469
|
+
|
413
470
|
def namespaced_block(command, &block)
|
414
471
|
redis.send(command) do |r|
|
415
472
|
begin
|
@@ -426,9 +483,10 @@ class Redis
|
|
426
483
|
|
427
484
|
case key
|
428
485
|
when Array
|
429
|
-
key.map {|k| add_namespace k}
|
486
|
+
key.map! {|k| add_namespace k}
|
430
487
|
when Hash
|
431
|
-
|
488
|
+
key.keys.each {|k| key[add_namespace(k)] = key.delete(k)}
|
489
|
+
key
|
432
490
|
else
|
433
491
|
"#{@namespace}:#{key}"
|
434
492
|
end
|
data/spec/deprecation_spec.rb
CHANGED
@@ -34,6 +34,7 @@ describe Redis::Namespace do
|
|
34
34
|
allow(redis).to receive(:unhandled) do |*args|
|
35
35
|
"unhandled(#{args.inspect})"
|
36
36
|
end
|
37
|
+
allow(redis).to receive(:flushdb).and_return("OK")
|
37
38
|
end
|
38
39
|
|
39
40
|
# This behaviour will hold true after the 2.x migration
|
@@ -50,6 +51,16 @@ describe Redis::Namespace do
|
|
50
51
|
end.to raise_exception NoMethodError
|
51
52
|
end
|
52
53
|
end
|
54
|
+
|
55
|
+
context('with an administrative command') do
|
56
|
+
it { should_not respond_to :flushdb }
|
57
|
+
|
58
|
+
it('raises a NoMethodError') do
|
59
|
+
expect do
|
60
|
+
namespaced.flushdb
|
61
|
+
end.to raise_exception NoMethodError
|
62
|
+
end
|
63
|
+
end
|
53
64
|
end
|
54
65
|
|
55
66
|
# This behaviour will no longer be available after the 2.x migration
|
@@ -77,6 +88,7 @@ describe Redis::Namespace do
|
|
77
88
|
|
78
89
|
expect(warning).to_not be_empty
|
79
90
|
expect(warning).to include %q(Passing 'unhandled' command to redis as is)
|
91
|
+
expect(warning).to include %q(blind passthrough)
|
80
92
|
expect(warning).to include __FILE__
|
81
93
|
end
|
82
94
|
|
@@ -87,10 +99,30 @@ describe Redis::Namespace do
|
|
87
99
|
namespaced.unhandled('bar')
|
88
100
|
end
|
89
101
|
warning = stderr.tap(&:rewind).read
|
102
|
+
|
90
103
|
expect(warning).to be_empty
|
91
104
|
end
|
92
105
|
end
|
93
106
|
end
|
107
|
+
|
108
|
+
context('with an administrative command') do
|
109
|
+
it { should respond_to :flushdb }
|
110
|
+
it 'processes the command' do
|
111
|
+
expect(redis).to receive(:flushdb)
|
112
|
+
capture_stderr { namespaced.flushdb }
|
113
|
+
end
|
114
|
+
it 'warns with helpful output' do
|
115
|
+
capture_stderr(stderr = StringIO.new) do
|
116
|
+
namespaced.flushdb
|
117
|
+
end
|
118
|
+
warning = stderr.tap(&:rewind).read
|
119
|
+
|
120
|
+
expect(warning).to_not be_empty
|
121
|
+
expect(warning).to include %q(Passing 'flushdb' command to redis as is)
|
122
|
+
expect(warning).to include %q(administrative)
|
123
|
+
expect(warning).to include __FILE__
|
124
|
+
end
|
125
|
+
end
|
94
126
|
end
|
95
127
|
end
|
96
128
|
end
|
data/spec/redis_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe "redis" do
|
|
12
12
|
|
13
13
|
before(:each) do
|
14
14
|
@namespaced = Redis::Namespace.new(:ns, :redis => @redis)
|
15
|
-
@
|
15
|
+
@redis.flushdb
|
16
16
|
@redis['foo'] = 'bar'
|
17
17
|
end
|
18
18
|
|
@@ -485,9 +485,17 @@ describe "redis" do
|
|
485
485
|
should eq(%w[ns:k1 ns:k2])
|
486
486
|
end
|
487
487
|
|
488
|
+
it "should namespace eval keys passed in as hash args unmodified" do
|
489
|
+
args = { :keys => %w[k1 k2], :argv => %w[arg1 arg2] }
|
490
|
+
args.freeze
|
491
|
+
@namespaced.
|
492
|
+
eval("return {KEYS[1], KEYS[2]}", args).
|
493
|
+
should eq(%w[ns:k1 ns:k2])
|
494
|
+
end
|
495
|
+
|
488
496
|
context '#evalsha' do
|
489
497
|
let!(:sha) do
|
490
|
-
@
|
498
|
+
@redis.script(:load, "return {KEYS[1], KEYS[2]}")
|
491
499
|
end
|
492
500
|
|
493
501
|
it "should namespace evalsha keys passed in as array args" do
|
@@ -501,11 +509,19 @@ describe "redis" do
|
|
501
509
|
evalsha(sha, :keys => %w[k1 k2], :argv => %w[arg1 arg2]).
|
502
510
|
should eq(%w[ns:k1 ns:k2])
|
503
511
|
end
|
512
|
+
|
513
|
+
it "should namespace evalsha keys passed in as hash args unmodified" do
|
514
|
+
args = { :keys => %w[k1 k2], :argv => %w[arg1 arg2] }
|
515
|
+
args.freeze
|
516
|
+
@namespaced.
|
517
|
+
evalsha(sha, args).
|
518
|
+
should eq(%w[ns:k1 ns:k2])
|
519
|
+
end
|
504
520
|
end
|
505
521
|
|
506
522
|
context "in a nested namespace" do
|
507
523
|
let(:nested_namespace) { Redis::Namespace.new(:nest, :redis => @namespaced) }
|
508
|
-
let(:sha) {
|
524
|
+
let(:sha) { @redis.script(:load, "return {KEYS[1], KEYS[2]}") }
|
509
525
|
|
510
526
|
it "should namespace eval keys passed in as hash args" do
|
511
527
|
nested_namespace.
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-namespace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
5
|
-
prerelease:
|
4
|
+
version: 1.5.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Chris Wanstrath
|
@@ -12,69 +11,60 @@ authors:
|
|
12
11
|
autorequire:
|
13
12
|
bindir: bin
|
14
13
|
cert_chain: []
|
15
|
-
date:
|
14
|
+
date: 2017-02-16 00:00:00.000000000 Z
|
16
15
|
dependencies:
|
17
16
|
- !ruby/object:Gem::Dependency
|
18
17
|
name: redis
|
19
18
|
requirement: !ruby/object:Gem::Requirement
|
20
|
-
none: false
|
21
19
|
requirements:
|
22
|
-
- - ~>
|
20
|
+
- - "~>"
|
23
21
|
- !ruby/object:Gem::Version
|
24
22
|
version: '3.0'
|
25
|
-
- -
|
23
|
+
- - ">="
|
26
24
|
- !ruby/object:Gem::Version
|
27
25
|
version: 3.0.4
|
28
26
|
type: :runtime
|
29
27
|
prerelease: false
|
30
28
|
version_requirements: !ruby/object:Gem::Requirement
|
31
|
-
none: false
|
32
29
|
requirements:
|
33
|
-
- - ~>
|
30
|
+
- - "~>"
|
34
31
|
- !ruby/object:Gem::Version
|
35
32
|
version: '3.0'
|
36
|
-
- -
|
33
|
+
- - ">="
|
37
34
|
- !ruby/object:Gem::Version
|
38
35
|
version: 3.0.4
|
39
36
|
- !ruby/object:Gem::Dependency
|
40
37
|
name: rake
|
41
38
|
requirement: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
39
|
requirements:
|
44
|
-
- - ~>
|
40
|
+
- - "~>"
|
45
41
|
- !ruby/object:Gem::Version
|
46
42
|
version: '10.1'
|
47
43
|
type: :development
|
48
44
|
prerelease: false
|
49
45
|
version_requirements: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
46
|
requirements:
|
52
|
-
- - ~>
|
47
|
+
- - "~>"
|
53
48
|
- !ruby/object:Gem::Version
|
54
49
|
version: '10.1'
|
55
50
|
- !ruby/object:Gem::Dependency
|
56
51
|
name: rspec
|
57
52
|
requirement: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
53
|
requirements:
|
60
|
-
- - ~>
|
54
|
+
- - "~>"
|
61
55
|
- !ruby/object:Gem::Version
|
62
56
|
version: '2.14'
|
63
57
|
type: :development
|
64
58
|
prerelease: false
|
65
59
|
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
60
|
requirements:
|
68
|
-
- - ~>
|
61
|
+
- - "~>"
|
69
62
|
- !ruby/object:Gem::Version
|
70
63
|
version: '2.14'
|
71
|
-
description:
|
72
|
-
|
64
|
+
description: |
|
65
|
+
Adds a Redis::Namespace class which can be used to namespace calls
|
73
66
|
to Redis. This is useful when using a single instance of Redis with
|
74
|
-
|
75
67
|
multiple, different applications.
|
76
|
-
|
77
|
-
'
|
78
68
|
email:
|
79
69
|
- chris@ozmm.org
|
80
70
|
- hone02@gmail.com
|
@@ -84,39 +74,37 @@ executables: []
|
|
84
74
|
extensions: []
|
85
75
|
extra_rdoc_files: []
|
86
76
|
files:
|
77
|
+
- LICENSE
|
87
78
|
- README.md
|
88
79
|
- Rakefile
|
89
|
-
- LICENSE
|
90
|
-
- lib/redis/namespace/version.rb
|
91
|
-
- lib/redis/namespace.rb
|
92
80
|
- lib/redis-namespace.rb
|
81
|
+
- lib/redis/namespace.rb
|
82
|
+
- lib/redis/namespace/version.rb
|
93
83
|
- spec/deprecation_spec.rb
|
94
84
|
- spec/redis_spec.rb
|
95
85
|
- spec/spec_helper.rb
|
96
86
|
homepage: http://github.com/resque/redis-namespace
|
97
87
|
licenses:
|
98
88
|
- MIT
|
89
|
+
metadata: {}
|
99
90
|
post_install_message:
|
100
91
|
rdoc_options: []
|
101
92
|
require_paths:
|
102
93
|
- lib
|
103
94
|
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
-
none: false
|
105
95
|
requirements:
|
106
|
-
- -
|
96
|
+
- - ">="
|
107
97
|
- !ruby/object:Gem::Version
|
108
98
|
version: '0'
|
109
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
-
none: false
|
111
100
|
requirements:
|
112
|
-
- -
|
101
|
+
- - ">="
|
113
102
|
- !ruby/object:Gem::Version
|
114
103
|
version: '0'
|
115
104
|
requirements: []
|
116
105
|
rubyforge_project:
|
117
|
-
rubygems_version:
|
106
|
+
rubygems_version: 2.5.1
|
118
107
|
signing_key:
|
119
|
-
specification_version:
|
108
|
+
specification_version: 4
|
120
109
|
summary: Namespaces Redis commands.
|
121
110
|
test_files: []
|
122
|
-
has_rdoc: false
|