File tree Expand file tree Collapse file tree 2 files changed +12
-34
lines changed Expand file tree Collapse file tree 2 files changed +12
-34
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ def call(*command)
76
76
77
77
# Queues a command for pipelining.
78
78
#
79
- # Commands in the queue are executed with the Redis::Client #commit method.
79
+ # Commands in the queue are executed with the Redis#commit method.
80
80
#
81
81
# See http://redis.io/topics/pipelining for more details.
82
82
#
Original file line number Diff line number Diff line change 3
3
require "cgi"
4
4
5
5
class Redis
6
- # Redis::Client handles the connection to Redis, sending and receiving commands.
7
- #
8
- # Usage:
9
- #
10
- # client = Redis::Client.new
11
- #
12
- # client.call(["PING"])
13
- # => "PONG"
14
- #
15
- # client.call(["SET", "key", "value"])
16
- # => "OK"
17
- #
18
- # client.call(["INCR", "key"])
19
- # => 1
20
- #
21
- # It provides an API for command pipelining:
22
- #
23
- # client.queue(["SET", "key", "value"])
24
- # client.queue(["GET", "key"])
25
- # client.commit
26
- # => ["OK", "value"]
27
- #
28
6
class Client
29
7
30
8
DEFAULTS = {
@@ -108,17 +86,6 @@ def initialize(options = {})
108
86
end
109
87
end
110
88
111
- def call ( command , &block )
112
- reply = process ( [ command ] ) { read }
113
- raise reply if reply . is_a? ( CommandError )
114
-
115
- if block
116
- block . call ( reply )
117
- else
118
- reply
119
- end
120
- end
121
-
122
89
def connect
123
90
@pid = Process . pid
124
91
@@ -141,6 +108,17 @@ def location
141
108
path || "#{ host } :#{ port } "
142
109
end
143
110
111
+ def call ( command , &block )
112
+ reply = process ( [ command ] ) { read }
113
+ raise reply if reply . is_a? ( CommandError )
114
+
115
+ if block
116
+ block . call ( reply )
117
+ else
118
+ reply
119
+ end
120
+ end
121
+
144
122
def call_loop ( command )
145
123
error = nil
146
124
You can’t perform that action at this time.
0 commit comments