redis-cluster 1.0.0.pre.rc.1 → 1.0.0.pre.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -9
- data/lib/redis-cluster.rb +2 -2
- data/lib/redis_cluster/client.rb +1 -1
- data/lib/redis_cluster/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87ff565ce3c8c2268935d56508aa5b5896a3f8eb
|
4
|
+
data.tar.gz: 474dd846727e7c52d56fea04333e0d35223026b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37eb706afca0090ea9a43bcf769ac86a06d2c423b8f20ebd9aa68a7631076ed165ab83ddc3fec015a92a3499b65f825c90ac453c7d8d74fa1bbee38e2c975235
|
7
|
+
data.tar.gz: b794604db2cf25cffbfbc92fd8120f9a7801f923f54ed077549d96f77a368f49b04dd8da33a60bb9c497a61a365aafb4c913a011e0f00f4445f2c140ebb3bcef
|
data/README.md
CHANGED
@@ -100,8 +100,9 @@ Option for RedisCluster.
|
|
100
100
|
Middlewares are hooks that RedisCluster provide to observe RedisCluster events. To register a middlewares, provide callable object (object that respond to call)
|
101
101
|
or give block in register method. Middlewares must give block result as return value.
|
102
102
|
````ruby
|
103
|
+
# Using callable
|
103
104
|
class Callable
|
104
|
-
call
|
105
|
+
def call
|
105
106
|
start = Time.now
|
106
107
|
yield
|
107
108
|
rescue StandardError => e
|
@@ -112,6 +113,7 @@ class Callable
|
|
112
113
|
end
|
113
114
|
redis.middlewares.register(:commit, Callable.new)
|
114
115
|
|
116
|
+
# Using proc
|
115
117
|
redis.middlewares.register(:commit) do |*args, &block|
|
116
118
|
begin
|
117
119
|
res = block.call
|
@@ -126,21 +128,23 @@ end
|
|
126
128
|
|
127
129
|
Currently there are 3 events that RedisCluster publish.
|
128
130
|
- `:commit`
|
129
|
-
RedisCluster will fire `:commit` events when RedisCluster::Client call redis server. It give
|
131
|
+
RedisCluster will fire `:commit` events when RedisCluster::Client call redis server. It give `RedisCluster::Client` as arguments.
|
130
132
|
````ruby
|
131
|
-
redis.middlewares.register(:commit) do |
|
133
|
+
redis.middlewares.register(:commit) do |client, &block|
|
132
134
|
puts 'this is :commit events'
|
133
|
-
puts "
|
134
|
-
puts "
|
135
|
+
puts "client url: #{client.url}"
|
136
|
+
puts "first command: #{client.queue.first.first}"
|
137
|
+
puts "last command: #{client.queue.last.first}"
|
135
138
|
block.call
|
136
139
|
end
|
137
140
|
````
|
138
141
|
- `:call`
|
139
|
-
This events is fired when command is issued in RedisCluster client before any load balancing is done. It give call arguments as arguments
|
142
|
+
This events is fired when command is issued in RedisCluster client before any load balancing is done. It give `RedisCluster` and `RedisCluster#call` arguments as arguments
|
140
143
|
````ruby
|
141
|
-
redis.middlewares.register(:call) do |keys, command, opts = {}, &block|
|
144
|
+
redis.middlewares.register(:call) do |client, keys, command, opts = {}, &block|
|
142
145
|
puts "keys to load balance: #{keys}"
|
143
146
|
puts "redis command: #{command.first}"
|
147
|
+
puts "in pipelined?: #{client.pipelined?}"
|
144
148
|
block.call
|
145
149
|
end
|
146
150
|
redis.get('something')
|
@@ -149,9 +153,9 @@ Currently there are 3 events that RedisCluster publish.
|
|
149
153
|
# redis command: get
|
150
154
|
````
|
151
155
|
- `:pipelined`
|
152
|
-
This events is fired when pipelined method is called from redis client. It does
|
156
|
+
This events is fired when pipelined method is called from redis client. It does give `RedisCluster` as arguments
|
153
157
|
````ruby
|
154
|
-
redis.middlewares.register(:pipelined) do
|
158
|
+
redis.middlewares.register(:pipelined) do |client, &block|
|
155
159
|
puts 'pipelined is called'
|
156
160
|
block.call
|
157
161
|
end
|
data/lib/redis-cluster.rb
CHANGED
@@ -47,13 +47,13 @@ class RedisCluster
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def call(*args, &block)
|
50
|
-
middlewares.invoke(:call, *args) do
|
50
|
+
middlewares.invoke(:call, self, *args) do
|
51
51
|
_call(*args, &block)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
55
|
def pipelined(*args, &block)
|
56
|
-
middlewares.invoke(:pipelined, *args) do
|
56
|
+
middlewares.invoke(:pipelined, self, *args) do
|
57
57
|
_pipelined(*args, &block)
|
58
58
|
end
|
59
59
|
end
|
data/lib/redis_cluster/client.rb
CHANGED