redis-cluster-client 0.7.9 → 0.7.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5aa02a0e3934e8246e948260f2a4457b324de2377e7ec2e00fe9bf03a52f5ee4
4
- data.tar.gz: 9f97a22af58eb64c64a6b73a79c2947bad06318e17bca235a5aa59fae35aad1d
3
+ metadata.gz: 84e0a41582397ffdb79a5bad130f849ef3980dd00e602908c76006224e0663ed
4
+ data.tar.gz: e987165bfcbbdda0ef5c122a88d36c21ebf7ade0ea6f8009203b7bb8a87a2736
5
5
  SHA512:
6
- metadata.gz: 2e8fcf1be08ba5c2582ad112455b02815410a81834b55bfc0035e0971556ff7b443e60a48a4cc2f5c94fdd81d09a5d03d3c261b4e0afb13ac9f38da5d4f0ab64
7
- data.tar.gz: 77f17d9e003384f34e5719f0e84f70c8a04f7de196974fc5af830e4825827b01d7df94b4eb887d4a1a4a77f43caa989cfdcbb1e874d807503bf9ef254ea95a0d
6
+ metadata.gz: 2bd0e3de07bad00ea4ade79f397c75ee4e9b244655bd3f5bb6ecfec9a25ca0c3893fb9fa135eb16d01b0c1b7747375c4e5d37c3683befe47fcc34bbd0c34d619
7
+ data.tar.gz: 5f84cd60815f57769ba3750f6f4e644ed4cdd933b5318ea4aa5ae725711c8ed87ea14e2ef252c92c66589645131e7a0a6381b2b8411fa56475768d2326cc69e6
@@ -18,9 +18,10 @@ class RedisClient
18
18
  @router.handle_redirection(node, retry_count: 1) do |nd|
19
19
  nd.with do |c|
20
20
  c.call('WATCH', *keys)
21
- reply = yield(c, slot)
21
+ yield(c, slot)
22
+ rescue StandardError
22
23
  c.call('UNWATCH')
23
- reply
24
+ raise
24
25
  end
25
26
  end
26
27
  end
@@ -8,6 +8,8 @@ require 'redis_client/cluster/key_slot_converter'
8
8
  require 'redis_client/cluster/node'
9
9
  require 'redis_client/cluster/node_key'
10
10
  require 'redis_client/cluster/normalized_cmd_name'
11
+ require 'redis_client/cluster/transaction'
12
+ require 'redis_client/cluster/optimistic_locking'
11
13
 
12
14
  class RedisClient
13
15
  class Cluster
@@ -44,6 +46,7 @@ class RedisClient
44
46
  when 'memory' then send_memory_command(method, command, args, &block)
45
47
  when 'script' then send_script_command(method, command, args, &block)
46
48
  when 'pubsub' then send_pubsub_command(method, command, args, &block)
49
+ when 'watch' then send_watch_command(command, &block)
47
50
  when 'acl', 'auth', 'bgrewriteaof', 'bgsave', 'quit', 'save'
48
51
  @node.call_all(method, command, args).first.then(&TSF.call(block))
49
52
  when 'flushall', 'flushdb'
@@ -308,6 +311,19 @@ class RedisClient
308
311
  end
309
312
  end
310
313
 
314
+ # for redis-rb
315
+ def send_watch_command(command)
316
+ raise ::RedisClient::Cluster::Transaction::ConsistencyError, 'A block required. And you need to use the block argument as a client for the transaction.' unless block_given?
317
+
318
+ ::RedisClient::Cluster::OptimisticLocking.new(self).watch(command[1..]) do |c, slot|
319
+ transaction = ::RedisClient::Cluster::Transaction.new(
320
+ self, @command_builder, node: c, slot: slot
321
+ )
322
+ yield transaction
323
+ transaction.execute
324
+ end
325
+ end
326
+
311
327
  def update_cluster_info!
312
328
  @node.reload!
313
329
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-cluster-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.9
4
+ version: 0.7.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taishi Kasuga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-18 00:00:00.000000000 Z
11
+ date: 2024-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-client