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 +4 -4
- data/README.md +12 -2
- data/lib/solid_redis/client.rb +4 -2
- data/lib/solid_redis/pool.rb +2 -2
- data/lib/solid_redis/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b8d43f81f25072d1e69cf2eb753ce70869745c2b60e5b7130681b77cce431907
|
|
4
|
+
data.tar.gz: 8829253e57de67c1b5ce46932849e0dd105ca49e0bf433aa88d4e3361e0c2f75
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
302
|
-
first `CommandError` if any;
|
|
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
|
data/lib/solid_redis/client.rb
CHANGED
|
@@ -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
|
-
|
|
37
|
+
if exception && (error = results.find { |result| result.is_a?(CommandError) })
|
|
38
|
+
raise error
|
|
39
|
+
end
|
|
38
40
|
|
|
39
41
|
results
|
|
40
42
|
end
|
data/lib/solid_redis/pool.rb
CHANGED
|
@@ -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
|
data/lib/solid_redis/version.rb
CHANGED
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.
|
|
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.
|
|
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:
|