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: c83ab40b9ae9fcca01d524c4c8668680c7e15fcf
4
- data.tar.gz: 48fe962f66e5408a852522337227f679b8859776
3
+ metadata.gz: 77dd86c44aa28c1d3769e3a2e94d0b65bb068aad
4
+ data.tar.gz: 1d2e7adb2ceea4e8573f5548bdbff67605fbe39c
5
5
  SHA512:
6
- metadata.gz: d42b3640f6a22d7c34e79d9d8b3edb5182ec4fa11e68c8d841ac84cee945942d2666e1c8cb6664c29c3bd78a7f96a06c54931b0bcc6591f82b588c71634fd6f3
7
- data.tar.gz: 81c2e002a0e49d2745e24da7b8148bf0a419b4dcb8afe87940941468484976b74fbaeb0bc9ef172eabf2d129aca1d0ae9fbafd06514ff81eac4ab75e6f45197a
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
- Redis.current.hset(belongs_to_#{model_name}_shadow_cache_key, self[self.class.primary_key], self.build_shadow_data)
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(shadow_cache_key, expiration)
55
+ Redis.current.expire(cache_key, expiration)
56
56
  end
57
57
  elsif expireat = self.class.shadow_options[:expireat]
58
- Redis.current.expireat(shadow_cache_key, expireat.to_i) if shadow_ttl < 0
58
+ Redis.current.expireat(cache_key, expireat.to_i) if shadow_ttl < 0
59
59
  end
60
60
  end
61
61
 
@@ -1,3 +1,3 @@
1
1
  module ShadowModel
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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.0
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.0.6
117
+ rubygems_version: 2.1.9
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: Rails model cache with redis