url_processor 0.5.5 → 0.5.6

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.
@@ -1,4 +1,22 @@
1
1
  module UrlProcessor
2
+ class Cache
3
+ def initialize
4
+ @memory = {}
5
+ end
6
+
7
+ def get(request)
8
+ @memory[request]
9
+ end
10
+
11
+ def set(request, response)
12
+ @memory[request] = response
13
+ end
14
+
15
+ def empty!
16
+ @memory.clear
17
+ end
18
+ end
19
+
2
20
  class Base
3
21
  attr_reader :config
4
22
 
@@ -78,6 +96,11 @@ module UrlProcessor
78
96
 
79
97
  def run
80
98
  processed_links = 0
99
+
100
+ # use an in-memory cache of responses (per run)
101
+ cache = Cache.new
102
+ Typhoeus::Config.cache = cache
103
+
81
104
  hydra = Typhoeus::Hydra.new(max_concurrency: config.max_concurrency, max_total_connections: config.max_total_connections)
82
105
 
83
106
  find_in_batches(config.links.call, config.batch_size) do |group|
@@ -135,6 +158,8 @@ module UrlProcessor
135
158
 
136
159
  hydra.run
137
160
  end
161
+
162
+ cache.empty!
138
163
  end
139
164
  end
140
165
  end
@@ -1,3 +1,3 @@
1
1
  module UrlProcessor
2
- VERSION = "0.5.5"
2
+ VERSION = "0.5.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: url_processor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-07 00:00:00.000000000 Z
12
+ date: 2014-05-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: typhoeus
@@ -186,7 +186,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
186
186
  version: '0'
187
187
  segments:
188
188
  - 0
189
- hash: -4358104254366073777
189
+ hash: 2447107549837569791
190
190
  required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  none: false
192
192
  requirements:
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  version: '0'
196
196
  segments:
197
197
  - 0
198
- hash: -4358104254366073777
198
+ hash: 2447107549837569791
199
199
  requirements: []
200
200
  rubyforge_project:
201
201
  rubygems_version: 1.8.23.2