redis-namespace 1.3.0 → 1.3.1
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 +15 -1
- data/spec/redis_spec.rb +27 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 838bcd2a161520a3d12b854bc1a441005c7a1d71
|
4
|
+
data.tar.gz: ea531ab8ea4ff3fcca0b23bdd98ca9e35eb43755
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2af8b6ac91666d5f686d700886637b70fca79374768b076f302540bcc739f1eacd8eec03849bc554e4891b4a99f11a525be481a972eb24fa315ca42b808f1390
|
7
|
+
data.tar.gz: 2cdff48f02a69335dd95a2c5ee5974cb4fff6676ff185e27a5d61de12ba5e00d2dc6da82aecccee538cc6c28e4d33e0e08d13f725afee7529fc5934aa200a298
|
data/lib/redis/namespace.rb
CHANGED
@@ -61,11 +61,13 @@ class Redis
|
|
61
61
|
"del" => [ :all ],
|
62
62
|
"discard" => [],
|
63
63
|
"dump" => [ :first ],
|
64
|
+
"echo" => [],
|
64
65
|
"exists" => [ :first ],
|
65
66
|
"expire" => [ :first ],
|
66
67
|
"expireat" => [ :first ],
|
67
68
|
"eval" => [ :eval_style ],
|
68
69
|
"evalsha" => [ :eval_style ],
|
70
|
+
"exec" => [],
|
69
71
|
"flushall" => [],
|
70
72
|
"flushdb" => [],
|
71
73
|
"get" => [ :first ],
|
@@ -152,6 +154,7 @@ class Redis
|
|
152
154
|
"spop" => [ :first ],
|
153
155
|
"srandmember" => [ :first ],
|
154
156
|
"srem" => [ :first ],
|
157
|
+
"strlen" => [ :first ],
|
155
158
|
"subscribe" => [ :all ],
|
156
159
|
"sunion" => [ :all ],
|
157
160
|
"sunionstore" => [ :all ],
|
@@ -217,7 +220,11 @@ class Redis
|
|
217
220
|
end
|
218
221
|
|
219
222
|
def multi(&block)
|
220
|
-
|
223
|
+
if block_given?
|
224
|
+
namespaced_block(:multi, &block)
|
225
|
+
else
|
226
|
+
method_missing(:multi)
|
227
|
+
end
|
221
228
|
end
|
222
229
|
|
223
230
|
def pipelined(&block)
|
@@ -233,6 +240,10 @@ class Redis
|
|
233
240
|
@namespace
|
234
241
|
end
|
235
242
|
|
243
|
+
def exec
|
244
|
+
method_missing(:exec)
|
245
|
+
end
|
246
|
+
|
236
247
|
def method_missing(command, *args, &block)
|
237
248
|
handling = COMMANDS[command.to_s] ||
|
238
249
|
COMMANDS[ALIASES[command.to_s]]
|
@@ -305,6 +316,9 @@ class Redis
|
|
305
316
|
# Dispatch the command to Redis and store the result.
|
306
317
|
result = @redis.send(command, *args, &block)
|
307
318
|
|
319
|
+
# Don't try to remove namespace from a Redis::Future, you can't.
|
320
|
+
return result if result.is_a?(Redis::Future)
|
321
|
+
|
308
322
|
# Remove the namespace from results that are keys.
|
309
323
|
case after
|
310
324
|
when :all
|
data/spec/redis_spec.rb
CHANGED
@@ -253,6 +253,24 @@ describe "redis" do
|
|
253
253
|
@namespaced.hgetall("foo").should eq({"key1" => "value1"})
|
254
254
|
end
|
255
255
|
|
256
|
+
it "should pass through multi commands without block" do
|
257
|
+
@namespaced.mapped_hmset "foo", {"key" => "value"}
|
258
|
+
|
259
|
+
@namespaced.multi
|
260
|
+
@namespaced.del "foo"
|
261
|
+
@namespaced.mapped_hmset "foo", {"key1" => "value1"}
|
262
|
+
@namespaced.exec
|
263
|
+
|
264
|
+
@namespaced.hgetall("foo").should eq({"key1" => "value1"})
|
265
|
+
end
|
266
|
+
|
267
|
+
it 'should return futures without attempting to remove namespaces' do
|
268
|
+
@namespaced.multi do
|
269
|
+
@future = @namespaced.keys('*')
|
270
|
+
end
|
271
|
+
@future.class.should be(Redis::Future)
|
272
|
+
end
|
273
|
+
|
256
274
|
it "should add namespace to pipelined blocks" do
|
257
275
|
@namespaced.mapped_hmset "foo", {"key" => "value"}
|
258
276
|
@namespaced.pipelined do |r|
|
@@ -271,6 +289,15 @@ describe "redis" do
|
|
271
289
|
result.should eq(["bar", "value"])
|
272
290
|
end
|
273
291
|
|
292
|
+
it "should add namespace to strlen" do
|
293
|
+
@namespaced.set("mykey", "123456")
|
294
|
+
@namespaced.strlen("mykey").should eq(6)
|
295
|
+
end
|
296
|
+
|
297
|
+
it "should not add namespace to echo" do
|
298
|
+
@namespaced.echo(123).should eq("123")
|
299
|
+
end
|
300
|
+
|
274
301
|
it "can change its namespace" do
|
275
302
|
@namespaced['foo'].should eq(nil)
|
276
303
|
@namespaced['foo'] = 'chris'
|
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.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wanstrath
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-08-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: redis
|
@@ -92,9 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
version: '0'
|
93
93
|
requirements: []
|
94
94
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.0.
|
95
|
+
rubygems_version: 2.0.2
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Namespaces Redis commands.
|
99
99
|
test_files: []
|
100
|
-
has_rdoc: false
|