Class: Redis::Cluster
- Defined in:
- lib/redis/cluster.rb,
lib/redis/cluster/client.rb,
lib/redis/cluster/version.rb,
lib/redis/cluster/transaction_adapter.rb
Defined Under Namespace
Classes: AmbiguousNodeError, Client, CommandErrorCollection, InitialSetupError, NodeMightBeDown, OrchestrationCommandNotSupported, TransactionAdapter, TransactionConsistencyError
Constant Summary collapse
- VERSION =
Redis::VERSION
Instance Method Summary collapse
-
#cluster(subcommand, *args) ⇒ Object
Sends ‘CLUSTER *` command to random node and returns its reply.
- #connection ⇒ Object
-
#initialize ⇒ Redis::Cluster
constructor
Create a new client instance.
-
#watch(*keys, &block) ⇒ Object
Watch the given keys to determine execution of the MULTI/EXEC block.
Constructor Details
#initialize ⇒ Redis::Cluster
Create a new client instance
68 69 70 |
# File 'lib/redis/cluster.rb', line 68 def initialize(*) # rubocop:disable Lint/UselessMethodDefinition super end |
Instance Method Details
#cluster(subcommand, *args) ⇒ Object
Sends ‘CLUSTER *` command to random node and returns its reply.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/redis/cluster.rb', line 81 def cluster(subcommand, *args) subcommand = subcommand.to_s.downcase block = case subcommand when 'slots' HashifyClusterSlots when 'nodes' HashifyClusterNodes when 'slaves' HashifyClusterSlaves when 'info' HashifyInfo else Noop end send_command([:cluster, subcommand] + args, &block) end |
#connection ⇒ Object
47 48 49 |
# File 'lib/redis/cluster.rb', line 47 def connection raise NotImplementedError, "Redis::Cluster doesn't implement #connection" end |
#watch(*keys, &block) ⇒ Object
Watch the given keys to determine execution of the MULTI/EXEC block.
Using a block is required for a cluster client. It’s different from a standalone client. And you should use the block argument as a receiver if you call commands.
An ‘#unwatch` is automatically issued if an exception is raised within the block that is a subclass of StandardError and is not a ConnectionError.
124 125 126 |
# File 'lib/redis/cluster.rb', line 124 def watch(*keys, &block) synchronize { |c| c.watch(*keys, &block) } end |