solid-redis 0.1.1 → 0.2.0

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
  SHA256:
3
- metadata.gz: e9cdb565b2c42299ce1e286ac7eb07dfdaa4fadbe91ad8eff2008a730d14b3f8
4
- data.tar.gz: dbc14ce529f4d359eabe77b476a56687e637aa94e5953210e40cef7da65bad5a
3
+ metadata.gz: b8d43f81f25072d1e69cf2eb753ce70869745c2b60e5b7130681b77cce431907
4
+ data.tar.gz: 8829253e57de67c1b5ce46932849e0dd105ca49e0bf433aa88d4e3361e0c2f75
5
5
  SHA512:
6
- metadata.gz: 9e1ce93fc017d9651eff97bfaf642e34dc6c090ea1c7708eeade64bf6a45235444c977cf4a18633bd3850977f9da67bcc2295e2635609401407fd2bf1c78c882
7
- data.tar.gz: 22058737facf0f458a049e0228fd87b3a4810efd107a6bcc949fd41751a0736aa959028e1102abbe56eba342560edaab3099341b5d120bb7da82421603f6837b
6
+ metadata.gz: 41e44bbd248002414a12a726376e9cbf2acad0825b163bab1633db89cc5ae4c1903776ec24c51cd0c59a26335999a0f5510a4dfc8052af6686495554cb135315
7
+ data.tar.gz: '01281e6eaf973aaff81ffeddeb346a4edf296461532b6f6207319dba8dcd2af3c6cd5e1581e1d73452892c128189c1695cde79348420b87ad4bf54c8bdb8598b'
data/README.md CHANGED
@@ -298,8 +298,9 @@ pool.close
298
298
  ### Pipelines and error handling
299
299
 
300
300
  `call` raises `SolidRedis::CommandError` on a Redis error reply. A pipeline
301
- sends all commands in one round trip, reads every reply, and then raises the
302
- first `CommandError` if any; the whole pipeline succeeds or raises.
301
+ sends all commands in one round trip and reads every reply. By default it
302
+ then raises the first `CommandError` if any; pass `exception: false` to get
303
+ errors back in place and keep the other results.
303
304
 
304
305
  ```ruby
305
306
  client = SolidRedis.config(url: "redis://localhost:6379").new_client
@@ -325,6 +326,15 @@ begin
325
326
  rescue SolidRedis::CommandError => error
326
327
  error.message # => "ERR value is not an integer or out of range"
327
328
  end
329
+
330
+ results = client.pipelined(exception: false) do |pipeline|
331
+ pipeline.call("SET", "counter", "abc")
332
+ pipeline.call("INCR", "counter")
333
+ pipeline.call("GET", "counter")
334
+ end
335
+ # => ["OK", #<SolidRedis::CommandError: ERR value is not an integer...>, "abc"]
336
+
337
+ results.each { |result| raise result if result.is_a?(SolidRedis::CommandError) }
328
338
  ```
329
339
 
330
340
  ### Building commands dynamically
@@ -26,7 +26,7 @@ module SolidRedis
26
26
  end
27
27
  end
28
28
 
29
- def pipelined
29
+ def pipelined(exception: true)
30
30
  pipeline = Pipeline.new
31
31
  yield pipeline
32
32
  return [] if pipeline.commands.empty?
@@ -34,7 +34,9 @@ module SolidRedis
34
34
  with_reconnect do
35
35
  write(pipeline.commands.map { |command| RESP.encode(command) }.join)
36
36
  results = pipeline.commands.map { @reader.read(exception: false) }
37
- raise results.find { |result| result.is_a?(CommandError) } if results.any?(CommandError)
37
+ if exception && (error = results.find { |result| result.is_a?(CommandError) })
38
+ raise error
39
+ end
38
40
 
39
41
  results
40
42
  end
@@ -37,8 +37,8 @@ module SolidRedis
37
37
  with { |client| client.call_v(command) }
38
38
  end
39
39
 
40
- def pipelined(&block)
41
- with { |client| client.pipelined(&block) }
40
+ def pipelined(exception: true, &block)
41
+ with { |client| client.pipelined(exception: exception, &block) }
42
42
  end
43
43
 
44
44
  def close
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidRedis
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Vandenbogaerde
@@ -95,7 +95,7 @@ licenses:
95
95
  - MIT
96
96
  metadata:
97
97
  rubygems_mfa_required: 'true'
98
- documentation_uri: https://www.rubydoc.info/gems/solid-redis/0.1.1
98
+ documentation_uri: https://www.rubydoc.info/gems/solid-redis/0.2.0
99
99
  source_code_uri: https://github.com/nicolasva/solid-redis
100
100
  rdoc_options: []
101
101
  require_paths: