redis-namespace 1.5.3 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redis/namespace.rb +8 -1
- data/lib/redis/namespace/version.rb +1 -1
- data/spec/redis_spec.rb +44 -39
- metadata +3 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08244a1c35f2f0164e72385ebd64aae7c57354b6'
|
4
|
+
data.tar.gz: dd76131303f0cbb576780146d9c5e3a759302e57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ca1e49aaf2c9e213a0859d1a0bda67f988ddf3a5af08bbf08388a8582298659d6a6869b7d8ee035501d8abf35779be20164dff5b849110f75f173cafb3444e5
|
7
|
+
data.tar.gz: ca1151681a327f2206370a12f63729ee4f9a0891830274fc0e219353137f09216757421cfb4d4d29c18f73ca2f6e2b7bcf8ff4a0dc55a88324cd0aa7957f2993
|
data/lib/redis/namespace.rb
CHANGED
@@ -241,6 +241,7 @@ class Redis
|
|
241
241
|
@deprecations = !!options.fetch(:deprecations) do
|
242
242
|
ENV['REDIS_NAMESPACE_DEPRECATIONS']
|
243
243
|
end
|
244
|
+
@has_new_client_method = @redis.respond_to?(:_client)
|
244
245
|
end
|
245
246
|
|
246
247
|
def deprecations?
|
@@ -252,7 +253,13 @@ class Redis
|
|
252
253
|
end
|
253
254
|
|
254
255
|
def client
|
255
|
-
|
256
|
+
warn("The client method is deprecated as of redis-rb 4.0.0, please use the new _client" +
|
257
|
+
"method instead. Support for the old method will be removed in redis-namespace 2.0.") if @has_new_client_method
|
258
|
+
_client
|
259
|
+
end
|
260
|
+
|
261
|
+
def _client
|
262
|
+
@has_new_client_method ? @redis._client : @redis.client # for redis-4.0.0
|
256
263
|
end
|
257
264
|
|
258
265
|
# Ruby defines a now deprecated type method so we need to override it here
|
data/spec/redis_spec.rb
CHANGED
@@ -4,6 +4,7 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
4
4
|
|
5
5
|
describe "redis" do
|
6
6
|
@redis_version = Gem::Version.new(Redis.current.info["redis_version"])
|
7
|
+
let(:redis_client) { @redis.respond_to?(:_client) ? @redis._client : @redis.client}
|
7
8
|
|
8
9
|
before(:all) do
|
9
10
|
# use database 15 for testing so we dont accidentally step on your real data
|
@@ -13,7 +14,7 @@ describe "redis" do
|
|
13
14
|
before(:each) do
|
14
15
|
@namespaced = Redis::Namespace.new(:ns, :redis => @redis)
|
15
16
|
@redis.flushdb
|
16
|
-
@redis
|
17
|
+
@redis.set('foo', 'bar')
|
17
18
|
end
|
18
19
|
|
19
20
|
after(:each) do
|
@@ -24,20 +25,24 @@ describe "redis" do
|
|
24
25
|
@redis.quit
|
25
26
|
end
|
26
27
|
|
27
|
-
it "proxies `client` to the
|
28
|
-
@namespaced.client.should eq(
|
28
|
+
it "proxies `client` to the _client and deprecated" do
|
29
|
+
@namespaced.client.should eq(redis_client)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "proxies `_client` to the _client" do
|
33
|
+
@namespaced._client.should eq(redis_client)
|
29
34
|
end
|
30
35
|
|
31
36
|
it "should be able to use a namespace" do
|
32
|
-
@namespaced
|
33
|
-
@namespaced
|
34
|
-
@namespaced
|
35
|
-
@redis
|
36
|
-
@redis
|
37
|
+
@namespaced.get('foo').should eq(nil)
|
38
|
+
@namespaced.set('foo', 'chris')
|
39
|
+
@namespaced.get('foo').should eq('chris')
|
40
|
+
@redis.set('foo', 'bob')
|
41
|
+
@redis.get('foo').should eq('bob')
|
37
42
|
|
38
43
|
@namespaced.incrby('counter', 2)
|
39
|
-
@namespaced
|
40
|
-
@redis
|
44
|
+
@namespaced.get('counter').to_i.should eq(2)
|
45
|
+
@redis.get('counter').should eq(nil)
|
41
46
|
@namespaced.type('counter').should eq('string')
|
42
47
|
end
|
43
48
|
|
@@ -60,21 +65,21 @@ describe "redis" do
|
|
60
65
|
end
|
61
66
|
|
62
67
|
it "should be able to use a namespace with del" do
|
63
|
-
@namespaced
|
64
|
-
@namespaced
|
65
|
-
@namespaced
|
68
|
+
@namespaced.set('foo', 1000)
|
69
|
+
@namespaced.set('bar', 2000)
|
70
|
+
@namespaced.set('baz', 3000)
|
66
71
|
@namespaced.del 'foo'
|
67
|
-
@namespaced
|
72
|
+
@namespaced.get('foo').should eq(nil)
|
68
73
|
@namespaced.del 'bar', 'baz'
|
69
|
-
@namespaced
|
70
|
-
@namespaced
|
74
|
+
@namespaced.get('bar').should eq(nil)
|
75
|
+
@namespaced.get('baz').should eq(nil)
|
71
76
|
end
|
72
77
|
|
73
78
|
it 'should be able to use a namespace with append' do
|
74
|
-
@namespaced
|
79
|
+
@namespaced.set('foo', 'bar')
|
75
80
|
@namespaced.append('foo','n').should eq(4)
|
76
|
-
@namespaced
|
77
|
-
@redis
|
81
|
+
@namespaced.get('foo').should eq('barn')
|
82
|
+
@redis.get('foo').should eq('bar')
|
78
83
|
end
|
79
84
|
|
80
85
|
it 'should be able to use a namespace with brpoplpush' do
|
@@ -124,15 +129,15 @@ describe "redis" do
|
|
124
129
|
|
125
130
|
it 'should be able to use a namespace with setrange' do
|
126
131
|
@namespaced.setrange('foo', 0, 'bar')
|
127
|
-
@namespaced
|
132
|
+
@namespaced.get('foo').should eq('bar')
|
128
133
|
|
129
134
|
@namespaced.setrange('bar', 2, 'foo')
|
130
|
-
@namespaced
|
135
|
+
@namespaced.get('bar').should eq("\000\000foo")
|
131
136
|
end
|
132
137
|
|
133
138
|
it "should be able to use a namespace with mget" do
|
134
|
-
@namespaced
|
135
|
-
@namespaced
|
139
|
+
@namespaced.set('foo', 1000)
|
140
|
+
@namespaced.set('bar', 2000)
|
136
141
|
@namespaced.mapped_mget('foo', 'bar').should eq({ 'foo' => '1000', 'bar' => '2000' })
|
137
142
|
@namespaced.mapped_mget('foo', 'baz', 'bar').should eq({'foo'=>'1000', 'bar'=>'2000', 'baz' => nil})
|
138
143
|
end
|
@@ -276,9 +281,9 @@ describe "redis" do
|
|
276
281
|
end
|
277
282
|
|
278
283
|
it "should yield the correct list of keys" do
|
279
|
-
@namespaced
|
280
|
-
@namespaced
|
281
|
-
@namespaced
|
284
|
+
@namespaced.set("foo", 1)
|
285
|
+
@namespaced.set("bar", 2)
|
286
|
+
@namespaced.set("baz", 3)
|
282
287
|
@namespaced.keys("*").sort.should eq(%w( bar baz foo ))
|
283
288
|
@namespaced.keys.sort.should eq(%w( bar baz foo ))
|
284
289
|
end
|
@@ -322,8 +327,8 @@ describe "redis" do
|
|
322
327
|
it "should returned response array from pipelined block" do
|
323
328
|
@namespaced.mset "foo", "bar", "key", "value"
|
324
329
|
result = @namespaced.pipelined do |r|
|
325
|
-
r
|
326
|
-
r
|
330
|
+
r.get("foo")
|
331
|
+
r.get("key")
|
327
332
|
end
|
328
333
|
result.should eq(["bar", "value"])
|
329
334
|
end
|
@@ -344,32 +349,32 @@ describe "redis" do
|
|
344
349
|
end
|
345
350
|
|
346
351
|
it "can change its namespace" do
|
347
|
-
@namespaced
|
348
|
-
@namespaced
|
349
|
-
@namespaced
|
352
|
+
@namespaced.get('foo').should eq(nil)
|
353
|
+
@namespaced.set('foo', 'chris')
|
354
|
+
@namespaced.get('foo').should eq('chris')
|
350
355
|
|
351
356
|
@namespaced.namespace.should eq(:ns)
|
352
357
|
@namespaced.namespace = :spec
|
353
358
|
@namespaced.namespace.should eq(:spec)
|
354
359
|
|
355
|
-
@namespaced
|
356
|
-
@namespaced
|
357
|
-
@namespaced
|
360
|
+
@namespaced.get('foo').should eq(nil)
|
361
|
+
@namespaced.set('foo', 'chris')
|
362
|
+
@namespaced.get('foo').should eq('chris')
|
358
363
|
end
|
359
364
|
|
360
365
|
it "can accept a temporary namespace" do
|
361
366
|
@namespaced.namespace.should eq(:ns)
|
362
|
-
@namespaced
|
367
|
+
@namespaced.get('foo').should eq(nil)
|
363
368
|
|
364
369
|
@namespaced.namespace(:spec) do |temp_ns|
|
365
370
|
temp_ns.namespace.should eq(:spec)
|
366
|
-
temp_ns
|
367
|
-
temp_ns
|
368
|
-
temp_ns
|
371
|
+
temp_ns.get('foo').should eq(nil)
|
372
|
+
temp_ns.set('foo', 'jake')
|
373
|
+
temp_ns.get('foo').should eq('jake')
|
369
374
|
end
|
370
375
|
|
371
376
|
@namespaced.namespace.should eq(:ns)
|
372
|
-
@namespaced
|
377
|
+
@namespaced.get('foo').should eq(nil)
|
373
378
|
end
|
374
379
|
|
375
380
|
it "should respond to :namespace=" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-namespace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wanstrath
|
@@ -11,15 +11,12 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2017-
|
14
|
+
date: 2017-11-03 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: redis
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|
19
19
|
requirements:
|
20
|
-
- - "~>"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '3.0'
|
23
20
|
- - ">="
|
24
21
|
- !ruby/object:Gem::Version
|
25
22
|
version: 3.0.4
|
@@ -27,9 +24,6 @@ dependencies:
|
|
27
24
|
prerelease: false
|
28
25
|
version_requirements: !ruby/object:Gem::Requirement
|
29
26
|
requirements:
|
30
|
-
- - "~>"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '3.0'
|
33
27
|
- - ">="
|
34
28
|
- !ruby/object:Gem::Version
|
35
29
|
version: 3.0.4
|
@@ -103,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
97
|
version: '0'
|
104
98
|
requirements: []
|
105
99
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.5.
|
100
|
+
rubygems_version: 2.5.2
|
107
101
|
signing_key:
|
108
102
|
specification_version: 4
|
109
103
|
summary: Namespaces Redis commands.
|