find_cache 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +7 -0
- data/lib/find_cache/cacheable.rb +2 -2
- data/lib/find_cache/version.rb +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -87,6 +87,13 @@ UserDetail (`belongs_to :user`) ->
|
|
87
87
|
|
88
88
|
## Notes
|
89
89
|
|
90
|
+
If your worker thread does not kill itself after execution you should clean the find_cache_store manually. It can be done simple in ApplicationController of your rails app adding this method as after_filter
|
91
|
+
after_filter :clean_find_cache_store
|
92
|
+
|
93
|
+
def clean_find_cache_store
|
94
|
+
FindCache::KeyGen.clean_global_cache
|
95
|
+
end
|
96
|
+
|
90
97
|
Tested with dalli (https://github.com/mperham/dalli).
|
91
98
|
|
92
99
|
## Credits
|
data/lib/find_cache/cacheable.rb
CHANGED
@@ -6,13 +6,13 @@ 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
|
-
Thread.current["#{attribute}_#{model}_#{foreign_key}"] ||= model.find_cache_by_ref(foreign_key, self.id)
|
9
|
+
Thread.current["#{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
|
-
Thread.current["#{attribute}_#{model}_#{foreign_key}"] ||= model.find_cache(self.send(foreign_key.to_sym))
|
15
|
+
Thread.current["#{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
|
data/lib/find_cache/version.rb
CHANGED