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 CHANGED
@@ -1,3 +1,10 @@
1
+ version 0.1.6
2
+ # after_commit on: :create, :update, :save instead of after_create, after_update, after_save callbacks
3
+ # fix thread cache key for dynamic class methods
4
+
5
+ version 0.1.5
6
+ # naming fix
7
+
1
8
  version 0.1.4
2
9
  # cache key bug fix
3
10
 
@@ -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
- Thread.current["#{attribute}_#{model}_#{foreign_key}_#{self.id}"] ||= model.find_cache_by_ref(foreign_key, self.id)
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
- Thread.current["#{attribute}_#{model}_#{foreign_key}_#{self.send(foreign_key.to_sym)}"] ||= model.find_cache(self.send(foreign_key.to_sym))
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
- after_save :expire_find_cache
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)
@@ -1,4 +1,4 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  module FindCache
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
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.5
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-25 00:00:00.000000000 Z
12
+ date: 2012-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord