async-redis 0.3.2 → 0.3.3

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: b52a198c6ffb4720f6cbe4531dc7fddfb5ff6eb3abf9f1cb587e28a42dcb5565
4
- data.tar.gz: 856bd3f53774a26f96bbe970afd96415a5a7fddf45eecec700a2c1b3400c8ac4
3
+ metadata.gz: 4908d7f5eef4279d5be275a46c17feb0d453f4c6bbc6e2cfa026eef027e518cc
4
+ data.tar.gz: 2dc99ed8cc6b160656b370a413118083787808104097382a7eac4e50b6cbb1be
5
5
  SHA512:
6
- metadata.gz: 910154257f90361014367ceeb7ac3328b541e46d22b883a087914b251c00fecb36b274e7c747800eb87ad5fcf7de1c4add9faae4c91807e47e89b0438d00c2a4
7
- data.tar.gz: 33291260be7de8a247fc3d7d31fe5f7c519229b71497e9f33b9541026ccd7c9b71ffbd8ed05a12d92387cf52d00c7b4fe61b27769b8a308cb38cc7f0478ce768
6
+ metadata.gz: 81bb8852f240c15d49670753acd9a1edba37911fd51c1594431e977d5e6b9bf8c31599523a5ce5a7c925b3674db5788bc2e764b0261ba43c07de67bf41822878
7
+ data.tar.gz: 2eb751bbc41d0a043139f19a33b031e3f40de3915f8e8c82b1e3cae3edab409689aaab0b73714a75fa96bfadb566bbfd1138478faf034c7e31fc5f3404877cb7
@@ -11,14 +11,13 @@ matrix:
11
11
  - rvm: 2.4
12
12
  - rvm: 2.5
13
13
  - rvm: 2.6
14
+ - rvm: 2.6
15
+ env: COVERAGE=BriefSummary,Coveralls
16
+ - rvm: ruby-head
14
17
  - rvm: truffleruby
15
18
  - rvm: jruby-head
16
19
  env: JRUBY_OPTS="--debug -X+O"
17
- - rvm: ruby-head
18
- - rvm: rbx-3
19
20
  allow_failures:
20
- - rvm: truffleruby
21
21
  - rvm: ruby-head
22
- - rvm: jruby-head
23
22
  - rvm: truffleruby
24
- - rvm: rbx-3
23
+ - rvm: jruby-head
data/Gemfile CHANGED
@@ -6,8 +6,3 @@ gemspec
6
6
  group :development do
7
7
  gem 'pry'
8
8
  end
9
-
10
- group :test do
11
- gem 'simplecov'
12
- gem 'coveralls', require: false
13
- end
data/Rakefile CHANGED
@@ -4,3 +4,15 @@ require "rspec/core/rake_task"
4
4
  RSpec::Core::RakeTask.new(:test)
5
5
 
6
6
  task :default => :test
7
+
8
+ task :client do
9
+ require 'irb'
10
+ require 'async/redis/client'
11
+
12
+ endpoint = Async::Redis.local_endpoint
13
+ client = Async::Redis::Client.new(endpoint)
14
+
15
+ Async do
16
+ binding.irb
17
+ end
18
+ end
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency "async-rspec", "~> 1.1"
24
24
 
25
+ spec.add_development_dependency "covered"
25
26
  spec.add_development_dependency "bundler"
26
27
  spec.add_development_dependency "rspec", "~> 3.6"
27
28
  spec.add_development_dependency "rake"
@@ -52,16 +52,20 @@ module Async
52
52
  attr :endpoint
53
53
  attr :protocol
54
54
 
55
+ # @return [client] if no block provided.
56
+ # @yield [client, task] yield the client in an async task.
55
57
  def self.open(*args, &block)
56
58
  client = self.new(*args)
57
59
 
58
60
  return client unless block_given?
59
61
 
60
- begin
61
- yield client
62
- ensure
63
- client.close
64
- end
62
+ Async do |task|
63
+ begin
64
+ yield client, task
65
+ ensure
66
+ client.close
67
+ end
68
+ end.wait
65
69
  end
66
70
 
67
71
  def close
@@ -99,6 +103,7 @@ module Async
99
103
  def call(*arguments)
100
104
  @pool.acquire do |connection|
101
105
  connection.write_request(arguments)
106
+
102
107
  return connection.read_response
103
108
  end
104
109
  end
@@ -38,6 +38,10 @@ module Async
38
38
 
39
39
  return metadata
40
40
  end
41
+
42
+ def flushdb!
43
+ call 'FLUSHDB'
44
+ end
41
45
  end
42
46
  end
43
47
  end
@@ -36,7 +36,6 @@ module Async
36
36
  @constructor = block
37
37
  end
38
38
 
39
-
40
39
  attr :resources
41
40
 
42
41
  def empty?
@@ -121,6 +121,26 @@ module Async
121
121
  end
122
122
 
123
123
  alias read_response read_object
124
+
125
+ private
126
+
127
+ # Override Async::IO::Protocol::Line#write_line
128
+ # The original method performs a flush. This one does not and moves the
129
+ # responsibility of flushing to the caller of the method.
130
+ # In the case of Redis, we do not want to perform a flush in every line,
131
+ # because each Redis command contains several lines. Flushing once per
132
+ # command is more efficient because it avoids unnecessary writes to the
133
+ # socket.
134
+ def write_lines(*args)
135
+ if args.empty?
136
+ @stream.write(@eol)
137
+ else
138
+ args.each do |arg|
139
+ @stream.write(arg)
140
+ @stream.write(@eol)
141
+ end
142
+ end
143
+ end
124
144
  end
125
145
  end
126
146
  end
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module Redis
23
- VERSION = "0.3.2"
23
+ VERSION = "0.3.3"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-02-18 00:00:00.000000000 Z
12
+ date: 2019-02-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: async
@@ -53,6 +53,20 @@ dependencies:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '1.1'
56
+ - !ruby/object:Gem::Dependency
57
+ name: covered
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: bundler
58
72
  requirement: !ruby/object:Gem::Requirement