shadow_model 0.2.0 → 0.2.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77dd86c44aa28c1d3769e3a2e94d0b65bb068aad
|
4
|
+
data.tar.gz: 1d2e7adb2ceea4e8573f5548bdbff67605fbe39c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fac0b344008998f6cf3aa8c480ddb31fa465c0fe388b4195035bccd81a124c598c3d53449e7523548c5acb7d194bbbb758d6d5af7a57d9ec8ba58e0f92eae7c
|
7
|
+
data.tar.gz: 6920f6940bbe251096e70334546d9fdd2b14949d831e24f35c1e41e378942435de947b3b18c4dc819d14c5f375d0db9e71c9dd183178f164750343b41ae3bd90
|
@@ -34,7 +34,9 @@ class ::ActiveRecord::Associations::Builder::HasMany
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def update_shadow_cach_of_#{model_name}
|
37
|
-
|
37
|
+
cache_key = belongs_to_#{model_name}_shadow_cache_key
|
38
|
+
Redis.current.hset(cache_key, self[self.class.primary_key], self.build_shadow_data)
|
39
|
+
update_expiration(cache_key)
|
38
40
|
end
|
39
41
|
|
40
42
|
def delete_shadow_cach_of_#{model_name}
|
@@ -46,16 +46,16 @@ module ShadowModel
|
|
46
46
|
def update_shadow_cache
|
47
47
|
return if shadow_options[:association_only]
|
48
48
|
Redis.current.set(shadow_cache_key, build_shadow_data)
|
49
|
-
update_expiration
|
49
|
+
update_expiration(shadow_cache_key)
|
50
50
|
end
|
51
51
|
|
52
|
-
def update_expiration
|
52
|
+
def update_expiration(cache_key)
|
53
53
|
if expiration = self.class.shadow_options[:expiration]
|
54
54
|
if self.class.shadow_options[:update_expiration] || shadow_ttl < 0
|
55
|
-
Redis.current.expire(
|
55
|
+
Redis.current.expire(cache_key, expiration)
|
56
56
|
end
|
57
57
|
elsif expireat = self.class.shadow_options[:expireat]
|
58
|
-
Redis.current.expireat(
|
58
|
+
Redis.current.expireat(cache_key, expireat.to_i) if shadow_ttl < 0
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
data/lib/shadow_model/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shadow_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Weihu Chen
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.
|
117
|
+
rubygems_version: 2.1.9
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: Rails model cache with redis
|