Skip to content

Commit 0805783

Browse files
committed
Refactor and enhance Redis::Distributed
1 parent 137716c commit 0805783

26 files changed

+767
-1224
lines changed

lib/redis.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ def self.current=(redis)
3434
# @option options [Array<String, Hash{Symbol => String, Integer}>] :cluster List of cluster nodes to contact
3535
# @option options [Boolean] :replica Whether to use readonly replica nodes in Redis Cluster or not
3636
# @option options [Class] :connector Class of custom connector
37+
# @option options [Hash] :distributed detail options for partitioning with client side consistent hashing (e.g. :nodes, :tag, :ring)
3738
#
3839
# @return [Redis] a new client instance
3940
def initialize(options = {})
4041
@options = options.dup
42+
client = Client
43+
client = Distributed::Partitioner if options.key?(:distributed)
4144
@cluster_mode = options.key?(:cluster)
42-
client = @cluster_mode ? Cluster : Client
45+
client = Cluster if @cluster_mode
4346
@original_client = @client = client.new(options)
4447
@queue = Hash.new { |h, k| h[k] = [] }
4548

@@ -3502,3 +3505,5 @@ def _xread(args, keys, ids, blocking_timeout_msec)
35023505
require_relative "redis/cluster"
35033506
require_relative "redis/pipeline"
35043507
require_relative "redis/subscribe"
3508+
require_relative 'redis/distributed'
3509+
require_relative 'redis/distributed/partitioner'

0 commit comments

Comments
 (0)