jit_preloader 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/jit_preloader/preloader.rb +14 -0
- data/lib/jit_preloader/version.rb +1 -1
- data/spec/lib/jit_preloader/preloader_spec.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dd36dd4639cc012aff19a8afdfb6bee699cdd1c
|
4
|
+
data.tar.gz: 41d7e22054a231edba2dc80ce3d19ac16e57cef9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cb4b5385ab0e3e7a321ac759372dbd6bd715141b89b92c82773c40f547bef92311bdfa365ad43a7b5d544c8983962f769d39a02949476fa660da305b59792d8
|
7
|
+
data.tar.gz: 5f24a4834a8bff484cdb849702ad71b62ddc10289134dbc1f6ad9431644015244a4ab252a6ddb74ac9d91ed47b9e1963af3cf2041fcd305e3eff0493cf1477b5
|
data/Gemfile.lock
CHANGED
@@ -19,5 +19,19 @@ module JitPreloader
|
|
19
19
|
preload records_with_association, association
|
20
20
|
end
|
21
21
|
|
22
|
+
# We do not want the jit_preloader to be dumpable
|
23
|
+
# If you dump a ActiveRecord::Base object that has a jit_preloader instance variable
|
24
|
+
# you will also end up dumping all of the records the preloader has reference to.
|
25
|
+
# Imagine getting N objects from a query and dumping each one of those into a cache
|
26
|
+
# each object would dump N+1 objects which means you'll end up storing O(N^2) memory. Thats no good.
|
27
|
+
# So instead, we will just nullify the jit_preloader on load
|
28
|
+
def _dump(level)
|
29
|
+
""
|
30
|
+
end
|
31
|
+
|
32
|
+
def self._load(args)
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
|
22
36
|
end
|
23
37
|
end
|
@@ -38,6 +38,19 @@ RSpec.describe JitPreloader::Preloader do
|
|
38
38
|
->(event, data){ source_map[data[:source]] << data[:association] }
|
39
39
|
end
|
40
40
|
|
41
|
+
context "when we marshal dump the active record object" do
|
42
|
+
it "nullifes the jit_preloader reference" do
|
43
|
+
contacts = Contact.jit_preload.to_a
|
44
|
+
reloaded_contacts = contacts.collect{|r| Marshal.load(Marshal.dump(r)) }
|
45
|
+
contacts.each do |c|
|
46
|
+
expect(c.jit_preloader).to_not be_nil
|
47
|
+
end
|
48
|
+
reloaded_contacts.each do |c|
|
49
|
+
expect(c.jit_preloader).to be_nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
41
54
|
context "when the preloader is globally enabled" do
|
42
55
|
around do |example|
|
43
56
|
JitPreloader.globally_enabled = true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jit_preloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle d'Oliveira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|