shadow_model 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/README.md +3 -3
- data/lib/shadow_model/extension.rb +5 -4
- data/lib/shadow_model/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3c9efb64ff1507c2a3bb52cfdb0f3cb5170cc11
|
4
|
+
data.tar.gz: eac4e8e566f6b430673ca18eaa331884e79558b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec6a1e6e66cdc55c9968882310e01884d70ab59c2e5072cbc4146431636b0661aeaf1762f5ea6dd13839f118c6dc9dae9edf957ccd037fdf8e8d7f6be4c30f73
|
7
|
+
data.tar.gz: 05815242f6983486b71d5a1b98b9f24c491f9242540d1dcefb6d0f4d4eb94e6424c31462c4b94dcca32f1a8ee8331b7b2700fea4ed9d794bbaf2089e45372d7f
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
A rails plugin use redis to cache models data.
|
4
4
|
|
5
|
-
[](https://travis-ci.org/cctiger36/shadow_model)
|
5
|
+
[](https://travis-ci.org/cctiger36/shadow_model) [](http://badge.fury.io/rb/shadow_model) [](https://coveralls.io/r/cctiger36/shadow_model) [](https://codeclimate.com/github/cctiger36/shadow_model)
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -29,11 +29,11 @@ And use this to retrieve the model from redis.
|
|
29
29
|
<table>
|
30
30
|
<tr>
|
31
31
|
<td>expiration</td><td>Set the timeout of each cache.</td>
|
32
|
-
<tr>
|
33
32
|
</tr>
|
33
|
+
<tr>
|
34
34
|
<td> update_expiration</td><td>Reset cache expiration after model updated.</td>
|
35
35
|
</tr>
|
36
|
-
|
36
|
+
<tr>
|
37
37
|
<td>expireat</td><td>Set the absolute timeout timestamp of each cache.</td>
|
38
38
|
</tr>
|
39
39
|
</table>
|
@@ -42,12 +42,12 @@ module ShadowModel
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def update_expiration
|
45
|
-
if self.class.shadow_options[:expiration]
|
45
|
+
if expiration = self.class.shadow_options[:expiration]
|
46
46
|
if self.class.shadow_options[:update_expiration] || shadow_ttl < 0
|
47
|
-
Redis.current.expire(shadow_cache_key,
|
47
|
+
Redis.current.expire(shadow_cache_key, expiration)
|
48
48
|
end
|
49
|
-
elsif self.class.shadow_options[:expireat]
|
50
|
-
Redis.current.expireat(shadow_cache_key,
|
49
|
+
elsif expireat = self.class.shadow_options[:expireat]
|
50
|
+
Redis.current.expireat(shadow_cache_key, expireat.to_i) if shadow_ttl < 0
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -67,6 +67,7 @@ module ShadowModel
|
|
67
67
|
@shadow_methods << arg.to_sym
|
68
68
|
end
|
69
69
|
end
|
70
|
+
@shadow_attributes << primary_key.to_sym if !@shadow_attributes.include?(primary_key.to_sym)
|
70
71
|
@shadow_attributes.each { |attr| define_shadow_attributes(attr) }
|
71
72
|
end
|
72
73
|
|
data/lib/shadow_model/version.rb
CHANGED