activerecord-collection_cache_key 0.1.1 → 0.1.2
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 +8 -0
- data/README.md +8 -5
- data/lib/collection_cache_key/cache_key.rb +1 -1
- data/lib/collection_cache_key/version.rb +1 -1
- 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: 07aede839494b5c41542a32614738d6a69c5200b
|
4
|
+
data.tar.gz: 88b7d562178f81990b67a3ece77f87c8a7358613
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d7f20f5dbe207988d0d2cfe70c9e75b7e9511bf9177fa56b561c68494738485cbd2c65cbe25268855d03f0b0bbebb44d3da7ea7a3cab099bce99c96ec832419
|
7
|
+
data.tar.gz: 808cdcec63c9bf56722949ac2332b246a0f6fca6213534af569988edec89fa8c0857fc24f4f022668d490205c2229c3131dc9f914e0bcaec83f520227a8fabb1
|
data/CHANGELOG.md
CHANGED
@@ -16,3 +16,11 @@ Bugfix
|
|
16
16
|
|
17
17
|
* Corrects a bug where models with a `#size` or `#timestamp` method could
|
18
18
|
fail to generate a proper cache key.
|
19
|
+
|
20
|
+
## v0.1.2 - 2016-04-26
|
21
|
+
|
22
|
+
Bugfix
|
23
|
+
|
24
|
+
* Corrects a bug in the PostgreSQL adapter where calling `first` when getting collection stats
|
25
|
+
adds an implicit `order_by` on an unselected column.
|
26
|
+
|
data/README.md
CHANGED
@@ -21,12 +21,15 @@ You can now access the key for any ActiveRecord collection via its `#cache_key`
|
|
21
21
|
@scope = MyModel.where(active: 1).cache_key
|
22
22
|
```
|
23
23
|
|
24
|
-
And then use it in your
|
24
|
+
And then use it in your controller:
|
25
25
|
|
26
|
-
```
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
```ruby
|
27
|
+
def index
|
28
|
+
@scope = MyModel.where(active: 1)
|
29
|
+
Rails.cache.fetch(@scope.cache_key) do
|
30
|
+
respond_with(@scope)
|
31
|
+
end
|
32
|
+
end
|
30
33
|
```
|
31
34
|
|
32
35
|
**Notes on Rails 3.x and `.all`:**
|
@@ -24,7 +24,7 @@ module CollectionCacheKey
|
|
24
24
|
def details_for(collection, timestamp_column)
|
25
25
|
column = "#{connection.quote_table_name(collection.table_name)}.#{connection.quote_column_name(timestamp_column)}"
|
26
26
|
query = collection.dup
|
27
|
-
result = query.select("COUNT(*) AS size, MAX(#{column}) AS timestamp").first
|
27
|
+
result = query.select("COUNT(*) AS size, MAX(#{column}) AS timestamp").to_a.first
|
28
28
|
attrs = result.attributes
|
29
29
|
|
30
30
|
[query_key(collection), attrs['size'], parsed_timestamp(attrs['timestamp'])]
|
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.2
|
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-04-
|
11
|
+
date: 2016-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|