redis 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/redis.rb +36 -7
- metadata +3 -3
data/lib/redis.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'socket'
|
2
2
|
|
3
3
|
class Redis
|
4
|
-
VERSION = "2.0.
|
4
|
+
VERSION = "2.0.3"
|
5
5
|
|
6
6
|
class ProtocolError < RuntimeError
|
7
7
|
def initialize(reply_type)
|
@@ -36,6 +36,10 @@ class Redis
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
def auth(password)
|
40
|
+
@client.call(:auth, password)
|
41
|
+
end
|
42
|
+
|
39
43
|
def select(db)
|
40
44
|
@client.db = db
|
41
45
|
@client.call(:select, db)
|
@@ -45,10 +49,20 @@ class Redis
|
|
45
49
|
Hash[*@client.call(:info).split(/:|\r\n/)]
|
46
50
|
end
|
47
51
|
|
52
|
+
def config(action, *args)
|
53
|
+
response = @client.call(:config, action, *args)
|
54
|
+
response = Hash[*response] if action == :get
|
55
|
+
response
|
56
|
+
end
|
57
|
+
|
48
58
|
def flushdb
|
49
59
|
@client.call(:flushdb)
|
50
60
|
end
|
51
61
|
|
62
|
+
def flushall
|
63
|
+
@client.call(:flushall)
|
64
|
+
end
|
65
|
+
|
52
66
|
def save
|
53
67
|
@client.call(:save)
|
54
68
|
end
|
@@ -57,6 +71,10 @@ class Redis
|
|
57
71
|
@client.call(:bgsave)
|
58
72
|
end
|
59
73
|
|
74
|
+
def bgrewriteaof
|
75
|
+
@client.call(:bgrewriteaof)
|
76
|
+
end
|
77
|
+
|
60
78
|
def get(key)
|
61
79
|
@client.call(:get, key)
|
62
80
|
end
|
@@ -352,6 +370,14 @@ class Redis
|
|
352
370
|
hmset(key, *hash.to_a.flatten)
|
353
371
|
end
|
354
372
|
|
373
|
+
def hmget(key, *fields)
|
374
|
+
@client.call(:hmget, key, *fields)
|
375
|
+
end
|
376
|
+
|
377
|
+
def mapped_hmget(key, *fields)
|
378
|
+
Hash[*fields.zip(hmget(key, *fields)).flatten]
|
379
|
+
end
|
380
|
+
|
355
381
|
def hlen(key)
|
356
382
|
@client.call(:hlen, key)
|
357
383
|
end
|
@@ -409,12 +435,7 @@ class Redis
|
|
409
435
|
end
|
410
436
|
|
411
437
|
def mapped_mget(*keys)
|
412
|
-
|
413
|
-
mget(*keys).each do |value|
|
414
|
-
key = keys.shift
|
415
|
-
result.merge!(key => value) unless value.nil?
|
416
|
-
end
|
417
|
-
result
|
438
|
+
Hash[*keys.zip(mget(*keys)).flatten]
|
418
439
|
end
|
419
440
|
|
420
441
|
def sort(key, options = {})
|
@@ -456,6 +477,14 @@ class Redis
|
|
456
477
|
@client.disconnect
|
457
478
|
end
|
458
479
|
|
480
|
+
def shutdown
|
481
|
+
@client.call(:shutdown)
|
482
|
+
end
|
483
|
+
|
484
|
+
def slaveof(host, port)
|
485
|
+
@client.call(:slaveof, host, port)
|
486
|
+
end
|
487
|
+
|
459
488
|
def pipelined
|
460
489
|
original, @client = @client, Pipeline.new
|
461
490
|
yield
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 2
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 2.0.
|
8
|
+
- 3
|
9
|
+
version: 2.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ezra Zygmuntowicz
|
@@ -21,7 +21,7 @@ autorequire: redis
|
|
21
21
|
bindir: bin
|
22
22
|
cert_chain: []
|
23
23
|
|
24
|
-
date: 2010-06-
|
24
|
+
date: 2010-06-22 00:00:00 -03:00
|
25
25
|
default_executable:
|
26
26
|
dependencies: []
|
27
27
|
|