typhoeus 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -124,6 +124,13 @@ static void rb_curl_multi_run(VALUE self, CURLM *multi_handle, int *still_runnin
124
124
  multi_read_info( self, multi_handle );
125
125
  }
126
126
 
127
+ static VALUE fire_and_forget(VALUE self) {
128
+ CurlMulti *curl_multi;
129
+ Data_Get_Struct(self, CurlMulti, curl_multi);
130
+ rb_curl_multi_run( self, curl_multi->multi, &(curl_multi->running) );
131
+ // curl_multi_perform(curl_multi->multi, 0);
132
+ }
133
+
127
134
  static VALUE multi_perform(VALUE self) {
128
135
  CURLMcode mcode;
129
136
  CurlMulti *curl_multi;
@@ -215,4 +222,5 @@ void init_typhoeus_multi() {
215
222
  rb_define_private_method(klass, "multi_perform", multi_perform, 0);
216
223
  rb_define_private_method(klass, "multi_cleanup", multi_cleanup, 0);
217
224
  rb_define_private_method(klass, "active_handle_count", active_handle_count, 0);
225
+ rb_define_method(klass, "fire_and_forget", fire_and_forget, 0);
218
226
  }
@@ -14,7 +14,7 @@ require 'typhoeus/request'
14
14
  require 'typhoeus/hydra'
15
15
 
16
16
  module Typhoeus
17
- VERSION = "0.1.4"
17
+ VERSION = "0.1.5"
18
18
 
19
19
  def self.easy_object_pool
20
20
  @easy_objects ||= []
@@ -1,6 +1,7 @@
1
1
  module Typhoeus
2
2
  class Hydra
3
3
  def initialize(initial_pool_size = 10)
4
+ @memoize_requests = true
4
5
  @multi = Multi.new
5
6
  @easy_pool = []
6
7
  initial_pool_size.times { @easy_pool << Easy.new }
@@ -20,12 +21,16 @@ module Typhoeus
20
21
  def clear_stubs
21
22
  @stubs = []
22
23
  end
24
+
25
+ def fire_and_forget
26
+ @multi.fire_and_forget
27
+ end
23
28
 
24
29
  def queue(request)
25
30
  return if assign_to_stub(request)
26
31
 
27
32
  if request.method == :get
28
- if @memoized_requests.has_key? request.url
33
+ if @memoize_requests && @memoized_requests.has_key?(request.url)
29
34
  if response = @retrieved_from_cache[request.url]
30
35
  request.response = response
31
36
  request.call_handlers
@@ -33,7 +38,7 @@ module Typhoeus
33
38
  @memoized_requests[request.url] << request
34
39
  end
35
40
  else
36
- @memoized_requests[request.url] = []
41
+ @memoized_requests[request.url] = [] if @memoize_requests
37
42
  get_from_cache_or_queue(request)
38
43
  end
39
44
  else
@@ -52,6 +57,10 @@ module Typhoeus
52
57
  @memoized_requests = {}
53
58
  @retrieved_from_cache = {}
54
59
  end
60
+
61
+ def disable_memoization
62
+ @memoize_requests = false
63
+ end
55
64
 
56
65
  def cache_getter(&block)
57
66
  @cache_getter = block
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typhoeus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Dix