redis-cluster-client 0.7.9 → 0.7.10

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: b591c92886bf877147317dd04695d2d22354958443f83e386b061b45b0407b28
4
+ data.tar.gz: 40a46369e32c60a3c165aff646d3dbd53c3ef427fef6220d4bacc17fc6a97232
5
5
  SHA512:
6
- metadata.gz: 2e8fcf1be08ba5c2582ad112455b02815410a81834b55bfc0035e0971556ff7b443e60a48a4cc2f5c94fdd81d09a5d03d3c261b4e0afb13ac9f38da5d4f0ab64
7
- data.tar.gz: 77f17d9e003384f34e5719f0e84f70c8a04f7de196974fc5af830e4825827b01d7df94b4eb887d4a1a4a77f43caa989cfdcbb1e874d807503bf9ef254ea95a0d
6
+ metadata.gz: 0e8eda475d22314feb84d16c2d5d75dfe714abecf2c6482a7600c012d02705110c40a0ed7717029a7e8ad154040c6cd44978ffd6b9a2c0350ec33e45d1e1b81e
7
+ data.tar.gz: a8fc2bb1febdac9e44c23aaab93ddce567d9ea1fe4ff09f74aa3ebac7eba56efceff44b5f13fea0284d4bec8b2677bd58dfee0eedfebe9cdc4ed9e7d4f6cb6df
@@ -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,17 @@ class RedisClient
308
311
  end
309
312
  end
310
313
 
314
+ # for redis-rb
315
+ def send_watch_command(command)
316
+ ::RedisClient::Cluster::OptimisticLocking.new(self).watch(command[1..]) do |c, slot|
317
+ transaction = ::RedisClient::Cluster::Transaction.new(
318
+ self, @command_builder, node: c, slot: slot
319
+ )
320
+ yield transaction
321
+ transaction.execute
322
+ end
323
+ end
324
+
311
325
  def update_cluster_info!
312
326
  @node.reload!
313
327
  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.10
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