activerecord-collection_cache_key 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/collection_cache_key/cache_key.rb +2 -1
- data/lib/collection_cache_key/version.rb +1 -1
- data/test/lib/collection_cache_key_test.rb +12 -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: ccd76e94d73ec763de6290eaae3ec459221513c1
|
4
|
+
data.tar.gz: 525b88d710b5a74411060ed912651a71ff79fb0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 788fcb1ebfcd065bd3786b8a7ef7d52b2b74e1e04660ebd5756689ea37f10bc607f5f4251ea2317750477674c1d66a4fbcaf7edea9341f658b9dc1109a9a4553
|
7
|
+
data.tar.gz: 1ef020a747534e3a6949f54d098a0ebedaa8855e9f8d37d086f31db6a25679e6321c40086306b8902635e3016c1ace119ab9f6844ab58704aee16ccb6ebbc81e
|
data/CHANGELOG.md
CHANGED
@@ -9,3 +9,10 @@ Initial Release
|
|
9
9
|
taken into account in the cache key; this will err toward expiring too much
|
10
10
|
rather than too little, and will *always* do a count query regardless of
|
11
11
|
whether the relation is loaded or not.
|
12
|
+
|
13
|
+
## v0.1.1 - 2016-04-01
|
14
|
+
|
15
|
+
Bugfix
|
16
|
+
|
17
|
+
* Corrects a bug where models with a `#size` or `#timestamp` method could
|
18
|
+
fail to generate a proper cache key.
|
@@ -25,8 +25,9 @@ module CollectionCacheKey
|
|
25
25
|
column = "#{connection.quote_table_name(collection.table_name)}.#{connection.quote_column_name(timestamp_column)}"
|
26
26
|
query = collection.dup
|
27
27
|
result = query.select("COUNT(*) AS size, MAX(#{column}) AS timestamp").first
|
28
|
+
attrs = result.attributes
|
28
29
|
|
29
|
-
[query_key(collection),
|
30
|
+
[query_key(collection), attrs['size'], parsed_timestamp(attrs['timestamp'])]
|
30
31
|
end
|
31
32
|
|
32
33
|
def query_key(collection)
|
@@ -35,6 +35,18 @@ class CollectionCacheKeyTest < CollectionCacheKey::TestCase
|
|
35
35
|
.must_equal("#{cache_namespace}/query-#{digest}-10-#{original_time_str}")
|
36
36
|
end
|
37
37
|
|
38
|
+
it 'avoids method name collisions with the key generation internals' do
|
39
|
+
subject.class_eval do
|
40
|
+
def size
|
41
|
+
999_999
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
digest = Digest::MD5.hexdigest(default_sql)
|
46
|
+
subject.collection_cache_key
|
47
|
+
.must_equal("#{cache_namespace}/query-#{digest}-10-#{original_time_str}")
|
48
|
+
end
|
49
|
+
|
38
50
|
it 'updates the cache_key when a record changes' do
|
39
51
|
subject.first.update_attributes(updated_at: update_time)
|
40
52
|
digest = Digest::MD5.hexdigest(default_sql)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-collection_cache_key
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Drinkard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|