find_cache 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGE-LOG +7 -0
- data/lib/find_cache/cacheable.rb +3 -5
- data/lib/find_cache/version.rb +1 -1
- metadata +2 -2
data/CHANGE-LOG
CHANGED
data/lib/find_cache/cacheable.rb
CHANGED
@@ -6,21 +6,19 @@ module FindCache
|
|
6
6
|
module ClassMethods
|
7
7
|
def find_cache_has_one(attribute, model, foreign_key)
|
8
8
|
send :define_method, attribute.to_sym do |*args|
|
9
|
-
|
9
|
+
$find_cache_store[KeyGen.global_cache_key]["#{attribute}_#{model}_#{foreign_key}_#{self.id}"] ||= model.find_cache_by_ref(foreign_key, self.id)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
def find_cache_belongs_to(attribute, model, foreign_key)
|
14
14
|
send :define_method, attribute.to_sym do |*args|
|
15
|
-
|
15
|
+
$find_cache_store[KeyGen.global_cache_key]["#{attribute}_#{model}_#{foreign_key}_#{self.send(foreign_key.to_sym)}"] ||= model.find_cache(self.send(foreign_key.to_sym))
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
included do
|
21
|
-
|
22
|
-
after_update :expire_find_cache
|
23
|
-
before_destroy :expire_find_cache
|
21
|
+
after_commit :expire_find_cache
|
24
22
|
|
25
23
|
def expire_find_cache
|
26
24
|
key = KeyGen.cache_key(self.class.name, self.id)
|
data/lib/find_cache/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: find_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|