find_cache 0.1.3 → 0.1.4

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.
@@ -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
@@ -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
@@ -1,4 +1,4 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  module FindCache
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
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.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: