redis_cluster 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 80d0d898c697524df7d413d0d776be6db761cf32
4
- data.tar.gz: 8d2c6b914846787fb0431e7b8eb95b0e416ddd02
3
+ metadata.gz: 4f7960de798b0e8a7a7f23671173cd8aac2e0817
4
+ data.tar.gz: 7ca5c777d03bd95f29fef19ec99af2338dff6893
5
5
  SHA512:
6
- metadata.gz: b27296df54145f1c0049c8988492c08a6a5c4d31769aeeeae56f0092d59fa8b8ce8c9f4aa438b98a695d13a9f3e19b2623109020bed0cb90eb52180639a98dbf
7
- data.tar.gz: a2c3433086109b5c71638ef4630a006bdbf45461a6f3511edaf02e425c2b613cbadee71dcf1a699a90310aeb198464a9918ebead0dcaf777adfc19f3ba16e8a4
6
+ metadata.gz: 172f1c6609af9bb0c4b835c730afc43b28ee83a3a1941d43c9aa08f9f97f403db4a024372a7bb7df4eea9e6c40aa4d1bac35daa4bdbe4581b15bc74400a0d987
7
+ data.tar.gz: a1cbf58a407fba42f413e12d8ff9bc907afc1a47fa14dfec4a7a5800569843c6e146ede14ae9d715318b9fb1202f18bfe23526c31584340bbed449b02b654681
data/README.md CHANGED
@@ -6,8 +6,6 @@ First see: [https://redis.io/topics/cluster-tutorial](https://redis.io/topics/cl
6
6
 
7
7
  RedisCluster for ruby is rewrited from [https://github.com/antirez/redis-rb-cluster](https://github.com/antirez/redis-rb-cluster)
8
8
 
9
- Now is developing, only support single node methods, and not use in any production environments.
10
-
11
9
 
12
10
  ## Installation
13
11
 
@@ -50,6 +50,8 @@ module RedisCluster
50
50
  private
51
51
 
52
52
  def reload_pool_nodes(raise_error = false)
53
+ return @pool.add_node!(@startup_hosts, [(0..Configuration::HASH_SLOTS)]) unless @startup_hosts.is_a? Array
54
+
53
55
  @mutex.synchronize do
54
56
  @startup_hosts.each do |options|
55
57
  begin
@@ -12,7 +12,7 @@ module RedisCluster
12
12
  hmset mapped_hmset hget hmget mapped_hmget hdel hexists hincrby hincrbyfloat hkeys hvals hgetall publish pfadd
13
13
  )
14
14
 
15
- SUPPORT_MULTI_NODE_METHODS = %w(keys)
15
+ SUPPORT_MULTI_NODE_METHODS = %w(keys multi pipelined)
16
16
  end
17
17
 
18
18
  end
@@ -24,7 +24,7 @@ module RedisCluster
24
24
  # asking
25
25
  # random_node
26
26
  def execute(method, args, other_options, &block)
27
- return send(method, args.first) if Configuration::SUPPORT_MULTI_NODE_METHODS.include?(method.to_s)
27
+ return send(method, args, &block) if Configuration::SUPPORT_MULTI_NODE_METHODS.include?(method.to_s)
28
28
 
29
29
  key = key_by_command(method, args)
30
30
  raise NotSupportError if key.nil?
@@ -34,10 +34,21 @@ module RedisCluster
34
34
  node.execute(method, args, &block)
35
35
  end
36
36
 
37
- def keys(glob = "*")
37
+ def keys(args, &block)
38
+ glob = args.first
38
39
  on_each_node(:keys, glob).flatten
39
40
  end
40
41
 
42
+ # Now mutli & pipelined conmand must control keys at same slot yourself
43
+ # You can use hash tag: '{foo}1'
44
+ def multi(args, &block)
45
+ random_node.execute :multi, args, &block
46
+ end
47
+
48
+ def pipelined(args, &block)
49
+ random_node.execute :pipelined, args, &block
50
+ end
51
+
41
52
  private
42
53
 
43
54
  def node_by(key)
@@ -51,7 +62,7 @@ module RedisCluster
51
62
 
52
63
  def key_by_command(method, args)
53
64
  case method.to_s.downcase
54
- when 'info', 'multi', 'exec', 'slaveof', 'config', 'shutdown'
65
+ when 'info', 'exec', 'slaveof', 'config', 'shutdown'
55
66
  nil
56
67
  else
57
68
  return args.first
@@ -3,7 +3,7 @@ module RedisCluster
3
3
  class Slot
4
4
  KEY_PATTERN = /\{([^\}]*)\}/
5
5
 
6
- # key "{xxx}ooo" will calculate "xxx" for slot
6
+ # has tag key "{xxx}ooo" will calculate "xxx" for slot
7
7
  # if key is "{}dddd", calculate "{}dddd" for slot
8
8
  def self.slot_by(key)
9
9
  key = key.to_s
@@ -1,3 +1,3 @@
1
1
  module RedisCluster
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_cluster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - wangzc
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-15 00:00:00.000000000 Z
11
+ date: 2017-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis