record-cache 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/lib/record_cache/datastore/active_record_30.rb +4 -5
- data/lib/record_cache/datastore/active_record_31.rb +4 -5
- data/lib/record_cache/datastore/active_record_32.rb +3 -4
- data/lib/record_cache/datastore/active_record_40.rb +1 -2
- data/lib/record_cache/datastore/active_record_41.rb +1 -2
- data/lib/record_cache/strategy/index_cache.rb +1 -1
- data/lib/record_cache/version.rb +1 -1
- data/spec/lib/strategy/index_cache_spec.rb +9 -0
- metadata +44 -30
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZmI3NDhhNzE0ZTcwZmZjNzZiNDhhMzg1Mjk2MDlkMjc1Njc0Zjg1NA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 57516bbd69db6900b46912a9944bd3804dabfeba
|
4
|
+
data.tar.gz: c656e1102f729260b073b191c11327268c520ec8
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ZjIxYTBkNzBlYWI1M2EwYTU2YTlkYTA0ZTNjZTEwMmY3YmQ0YmFkMWU4MjMz
|
11
|
-
MDUyYjE1OWYxNDM3YzQ3ZGRlZjZhMjBkODUzZjNmNzUyNzRmNjA=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MGRkZjIwZGVhNTgzNjU0NmFlMWQyOGRiMzZkZTY5MmU4MDlhM2VlZWYwNTQ3
|
14
|
-
NmY3NzliYjM1ZWE1NjI1Yzg1YTc2ZjVkNzY5OGE2MjFlZmNiODMxNDBiNWVk
|
15
|
-
YjYxYTU2YWFlZDQ3MjhlMGFjZTdlYjM5NjBkY2YyNjEzMjY1ZGE=
|
6
|
+
metadata.gz: 11c582d314e58fedd7537cbf7dcd5e4021bcf71d8ce7df7d6de0eb42edb13ea9214e742f56ee47e36583518ec670c4cd48a21396b4293b062bf56444c38b8b53
|
7
|
+
data.tar.gz: d0e9bccbcb2972412533941a7bf3d449b1e8884f1f73bcf68118d6e1b8d86f82ac3fc593b83d75046d2eb7860f25effe4d0ce2c6da53d068df5a6868606eb3dd
|
@@ -32,11 +32,10 @@ module RecordCache
|
|
32
32
|
arel = sql.instance_variable_get(:@arel)
|
33
33
|
sanitized_sql = sanitize_sql(sql)
|
34
34
|
|
35
|
-
records = if connection.
|
36
|
-
query_cache
|
37
|
-
query_cache["rc/#{sanitized_sql}"] ||= try_record_cache(sanitized_sql, arel)
|
35
|
+
records = if connection.query_cache_enabled
|
36
|
+
connection.query_cache["rc/#{sanitized_sql}"] ||= try_record_cache(sanitized_sql, arel)
|
38
37
|
elsif connection.open_transactions > RC_TRANSACTIONS_THRESHOLD
|
39
|
-
connection.
|
38
|
+
connection.select_all(sanitized_sql, "#{name} Load")
|
40
39
|
else
|
41
40
|
try_record_cache(sanitized_sql, arel)
|
42
41
|
end
|
@@ -47,7 +46,7 @@ module RecordCache
|
|
47
46
|
def try_record_cache(sql, arel)
|
48
47
|
query = arel && arel.respond_to?(:ast) ? RecordCache::Arel::QueryVisitor.new.accept(arel.ast) : nil
|
49
48
|
record_cache.fetch(query) do
|
50
|
-
connection.
|
49
|
+
connection.select_all(sql, "#{name} Load")
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
@@ -35,11 +35,10 @@ module RecordCache
|
|
35
35
|
sanitized_sql = sanitize_sql(sql)
|
36
36
|
sanitized_sql = connection.visitor.accept(sanitized_sql.ast) if sanitized_sql.respond_to?(:ast)
|
37
37
|
|
38
|
-
records = if connection.
|
39
|
-
query_cache
|
40
|
-
query_cache["rc/#{sanitized_sql}"][binds] ||= try_record_cache(arel, sanitized_sql, binds)
|
38
|
+
records = if connection.query_cache_enabled
|
39
|
+
connection.query_cache["rc/#{sanitized_sql}"][binds] ||= try_record_cache(arel, sanitized_sql, binds)
|
41
40
|
elsif connection.open_transactions > RC_TRANSACTIONS_THRESHOLD
|
42
|
-
connection.
|
41
|
+
connection.select_all(sanitized_sql, "#{name} Load", binds)
|
43
42
|
else
|
44
43
|
try_record_cache(arel, sanitized_sql, binds)
|
45
44
|
end
|
@@ -50,7 +49,7 @@ module RecordCache
|
|
50
49
|
def try_record_cache(arel, sql, binds)
|
51
50
|
query = arel && arel.respond_to?(:ast) ? RecordCache::Arel::QueryVisitor.new(binds).accept(arel.ast) : nil
|
52
51
|
record_cache.fetch(query) do
|
53
|
-
connection.
|
52
|
+
connection.select_all(sql, "#{name} Load", binds)
|
54
53
|
end
|
55
54
|
end
|
56
55
|
|
@@ -36,10 +36,9 @@ module RecordCache
|
|
36
36
|
sanitized_sql = connection.to_sql(sanitized_sql, binds.dup) if sanitized_sql.respond_to?(:ast)
|
37
37
|
|
38
38
|
records = if connection.query_cache_enabled
|
39
|
-
query_cache
|
40
|
-
query_cache["rc/#{sanitized_sql}"][binds] ||= try_record_cache(arel, sanitized_sql, binds)
|
39
|
+
connection.query_cache["rc/#{sanitized_sql}"][binds] ||= try_record_cache(arel, sanitized_sql, binds)
|
41
40
|
elsif connection.open_transactions > RC_TRANSACTIONS_THRESHOLD
|
42
|
-
connection.
|
41
|
+
connection.select_all(sanitized_sql, "#{name} Load", binds)
|
43
42
|
else
|
44
43
|
try_record_cache(arel, sanitized_sql, binds)
|
45
44
|
end
|
@@ -51,7 +50,7 @@ module RecordCache
|
|
51
50
|
def try_record_cache(arel, sql, binds)
|
52
51
|
query = arel && arel.respond_to?(:ast) ? RecordCache::Arel::QueryVisitor.new(binds).accept(arel.ast) : nil
|
53
52
|
record_cache.fetch(query) do
|
54
|
-
connection.
|
53
|
+
connection.select_all(sql, "#{name} Load", binds)
|
55
54
|
end
|
56
55
|
end
|
57
56
|
|
@@ -36,8 +36,7 @@ module RecordCache
|
|
36
36
|
sanitized_sql = connection.to_sql(sanitized_sql, binds) if sanitized_sql.respond_to?(:ast)
|
37
37
|
|
38
38
|
records = if connection.query_cache_enabled
|
39
|
-
query_cache
|
40
|
-
query_cache["rc/#{sanitized_sql}"][binds] ||= try_record_cache(arel, sql, binds)
|
39
|
+
connection.query_cache["rc/#{sanitized_sql}"][binds] ||= try_record_cache(arel, sql, binds)
|
41
40
|
|
42
41
|
elsif connection.open_transactions > RC_TRANSACTIONS_THRESHOLD
|
43
42
|
find_by_sql_without_record_cache(sql, binds)
|
@@ -36,8 +36,7 @@ module RecordCache
|
|
36
36
|
sanitized_sql = connection.to_sql(sanitized_sql, binds) if sanitized_sql.respond_to?(:ast)
|
37
37
|
|
38
38
|
records = if connection.query_cache_enabled
|
39
|
-
query_cache
|
40
|
-
query_cache["rc/#{sanitized_sql}"][binds] ||= try_record_cache(arel, sql, binds)
|
39
|
+
connection.query_cache["rc/#{sanitized_sql}"][binds] ||= try_record_cache(arel, sql, binds)
|
41
40
|
|
42
41
|
elsif connection.open_transactions > RC_TRANSACTIONS_THRESHOLD
|
43
42
|
find_by_sql_without_record_cache(sql, binds)
|
@@ -103,7 +103,7 @@ module RecordCache
|
|
103
103
|
# retrieve local version and increment version store
|
104
104
|
key = cache_key(value)
|
105
105
|
old_version = version_store.current(key)
|
106
|
-
new_version = version_store.renew(key, version_opts)
|
106
|
+
new_version = version_store.renew(key, true, version_opts)
|
107
107
|
# try to update the ids list based on the last version
|
108
108
|
ids = fetch_ids_from_cache(versioned_key(key, old_version))
|
109
109
|
if ids
|
data/lib/record_cache/version.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'timecop'
|
2
3
|
|
3
4
|
RSpec.describe RecordCache::Strategy::IndexCache do
|
4
5
|
|
@@ -252,6 +253,14 @@ RSpec.describe RecordCache::Strategy::IndexCache do
|
|
252
253
|
address.name = 'updated name'
|
253
254
|
address.save!
|
254
255
|
end
|
256
|
+
|
257
|
+
it "should honor version store TTL" do
|
258
|
+
Apple.record_cache[:store_id].invalidate(1)
|
259
|
+
expect(RecordCache::Base.version_store.store.read('rc/apl/1')).not_to be_nil
|
260
|
+
Timecop.travel(1.hour.from_now) do
|
261
|
+
expect(RecordCache::Base.version_store.store.read('rc/apl/1')).to be_nil
|
262
|
+
end
|
263
|
+
end
|
255
264
|
end
|
256
265
|
|
257
266
|
context 'subclassing' do
|
metadata
CHANGED
@@ -1,181 +1,195 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: record-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Orslumen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: activerecord
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - <
|
45
|
+
- - "<"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '4.2'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - <
|
52
|
+
- - "<"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '4.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: sqlite3
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pry
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: mysql2
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: simplecov
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rspec
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - ~>
|
129
|
+
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '3.0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - ~>
|
136
|
+
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '3.0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: database_cleaner
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
150
|
+
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: appraisal
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- -
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '0'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- -
|
164
|
+
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: test_after_commit
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- -
|
171
|
+
- - ">="
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '0'
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- -
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: timecop
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
179
193
|
- !ruby/object:Gem::Version
|
180
194
|
version: '0'
|
181
195
|
description: Record Cache for Rails 3
|
@@ -247,20 +261,20 @@ require_paths:
|
|
247
261
|
- lib
|
248
262
|
required_ruby_version: !ruby/object:Gem::Requirement
|
249
263
|
requirements:
|
250
|
-
- -
|
264
|
+
- - ">="
|
251
265
|
- !ruby/object:Gem::Version
|
252
266
|
version: '0'
|
253
267
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
254
268
|
requirements:
|
255
|
-
- -
|
269
|
+
- - ">="
|
256
270
|
- !ruby/object:Gem::Version
|
257
271
|
version: '0'
|
258
272
|
requirements: []
|
259
273
|
rubyforge_project:
|
260
|
-
rubygems_version: 2.
|
274
|
+
rubygems_version: 2.2.2
|
261
275
|
signing_key:
|
262
276
|
specification_version: 4
|
263
|
-
summary: Record Cache v0.1.
|
277
|
+
summary: Record Cache v0.1.6 transparantly stores Records in a Cache Store and retrieve
|
264
278
|
those Records from the store when queried using Active Model.
|
265
279
|
test_files:
|
266
280
|
- spec/db/create-record-cache-db_and_user.sql
|