perforated 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/CHANGELOG.md +6 -0
- data/lib/perforated/cache.rb +1 -4
- data/lib/perforated/version.rb +1 -1
- data/spec/perforated_spec.rb +1 -1
- metadata +3 -6
- data/lib/perforated/compatibility/find_in_batches.rb +0 -11
- data/spec/perforated/compatibility/find_in_batches_spec.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 330c81a4281ebab097c307068577fcd027ff4aec
|
4
|
+
data.tar.gz: e29c1d1b11c2e4e4b696fcd5a3c28c3828bbcc33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33ee71b9c0efcd1740583c7f21885ef6fa32e24b3079bc834f111fa180421ad55d059d7c3aad67a1a69151bf6644ffe79b4cfc1dbc9aadde4266d97f21e401f7
|
7
|
+
data.tar.gz: 54253903fd62fe2e050ed1545862346cd15d2190494e22cb43dbbeb168205e4290460cb633b359f159c8b6a80fc403ef6795f53ea1a2008e7e03b7a6ab06d914
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## Version 0.9.1
|
2
|
+
|
3
|
+
* To preserve the order and limit of ActiveRecord Relations, use of
|
4
|
+
`ActiveRecord::Relation#find_in_batches` has been removed in favor of
|
5
|
+
`Enumerable#each_slice` during batch caching.
|
6
|
+
|
1
7
|
## Version 0.9.0
|
2
8
|
|
3
9
|
* `as_json` and `to_json` now take a block. The block will be applied to each
|
data/lib/perforated/cache.rb
CHANGED
@@ -1,12 +1,9 @@
|
|
1
1
|
require 'perforated/rebuilder'
|
2
2
|
require 'perforated/strategy'
|
3
|
-
require 'perforated/compatibility/find_in_batches'
|
4
3
|
require 'perforated/compatibility/fetch_multi'
|
5
4
|
|
6
5
|
module Perforated
|
7
6
|
class Cache
|
8
|
-
using Perforated::Compatibility::FindInBatches
|
9
|
-
|
10
7
|
attr_accessor :enumerable, :strategy
|
11
8
|
|
12
9
|
def initialize(enumerable, strategy = Perforated::Strategy)
|
@@ -17,7 +14,7 @@ module Perforated
|
|
17
14
|
def to_json(rooted: false, batch_size: 1000, &block)
|
18
15
|
results = []
|
19
16
|
|
20
|
-
enumerable.
|
17
|
+
enumerable.each_slice(batch_size) do |subset|
|
21
18
|
keyed = key_mapped(subset)
|
22
19
|
|
23
20
|
results << fetch_multi(keyed) do |key|
|
data/lib/perforated/version.rb
CHANGED
data/spec/perforated_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: perforated
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Parker Selbert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -86,14 +86,12 @@ files:
|
|
86
86
|
- lib/perforated.rb
|
87
87
|
- lib/perforated/cache.rb
|
88
88
|
- lib/perforated/compatibility/fetch_multi.rb
|
89
|
-
- lib/perforated/compatibility/find_in_batches.rb
|
90
89
|
- lib/perforated/rebuilder.rb
|
91
90
|
- lib/perforated/strategy.rb
|
92
91
|
- lib/perforated/version.rb
|
93
92
|
- perforated.gemspec
|
94
93
|
- spec/perforated/cache_spec.rb
|
95
94
|
- spec/perforated/compatibility/fetch_multi_spec.rb
|
96
|
-
- spec/perforated/compatibility/find_in_batches_spec.rb
|
97
95
|
- spec/perforated/rebuilder_spec.rb
|
98
96
|
- spec/perforated_spec.rb
|
99
97
|
- spec/spec_helper.rb
|
@@ -117,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
115
|
version: '0'
|
118
116
|
requirements: []
|
119
117
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
118
|
+
rubygems_version: 2.2.2
|
121
119
|
signing_key:
|
122
120
|
specification_version: 4
|
123
121
|
summary: 'The most expensive part of serving a JSON request is converting the serialized
|
@@ -127,7 +125,6 @@ summary: 'The most expensive part of serving a JSON request is converting the se
|
|
127
125
|
test_files:
|
128
126
|
- spec/perforated/cache_spec.rb
|
129
127
|
- spec/perforated/compatibility/fetch_multi_spec.rb
|
130
|
-
- spec/perforated/compatibility/find_in_batches_spec.rb
|
131
128
|
- spec/perforated/rebuilder_spec.rb
|
132
129
|
- spec/perforated_spec.rb
|
133
130
|
- spec/spec_helper.rb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'perforated/compatibility/find_in_batches'
|
2
|
-
|
3
|
-
describe Perforated::Compatibility::FindInBatches do
|
4
|
-
FindBatches = Struct.new(:array) do
|
5
|
-
using Perforated::Compatibility::FindInBatches
|
6
|
-
|
7
|
-
def perform(&block)
|
8
|
-
array.find_in_batches(batch_size: 50, &block)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '#find_in_batches' do
|
13
|
-
it 'iterates over an enumerable in batches' do
|
14
|
-
enumerable = [1] * 100
|
15
|
-
eachable = FindBatches.new(enumerable)
|
16
|
-
results = []
|
17
|
-
|
18
|
-
eachable.perform do |arr|
|
19
|
-
results << arr.reduce(&:+)
|
20
|
-
end
|
21
|
-
|
22
|
-
expect(results).to eq([50, 50])
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|