cache_money_millionaire 0.0.1 → 0.0.2
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.
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["john@kohactive.com"]
|
11
11
|
spec.description = "Rails ActiveRecord Query Caching like a Millionaire"
|
12
12
|
spec.summary = "Rails ActiveRecord Query Caching like a Millionaire"
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/johnkoht/cache-money-millionaire"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
@@ -21,7 +21,10 @@ module ActiveRecord
|
|
21
21
|
# If it's cacheable and cache isn't set to false, then let's CacheMoneyMillionaire this bitch!
|
22
22
|
# We set the cache key to the object class name and id, i.e. Post 3, User 109, etc.
|
23
23
|
if CacheMoneyMillionaire.cacheable? and cache
|
24
|
-
|
24
|
+
puts "#{self} #{args[0]}"
|
25
|
+
cache_key = Digest::MD5.hexdigest "#{self} #{args[0]}"
|
26
|
+
puts cache_key.inspect
|
27
|
+
model = Rails.cache.fetch cache_key, expires_in: CacheMoneyMillionaire.options[:expires_in] do
|
25
28
|
super *args
|
26
29
|
end
|
27
30
|
else
|
@@ -53,6 +56,15 @@ module ActiveRecord
|
|
53
56
|
if CacheMoneyMillionaire.cacheable?
|
54
57
|
cache_key = Digest::MD5.hexdigest "#{self.class.name} #{self.id}"
|
55
58
|
Rails.cache.write cache_key, self
|
59
|
+
|
60
|
+
# Friendly id patch
|
61
|
+
# If you're using friendly id, then a slug is probably passed, passed as the parameter, instead of
|
62
|
+
# the ID. This will check if the model responds to friend_id, if so, it will create an additional
|
63
|
+
# cache_key with the slug
|
64
|
+
if self.respond_to? :friendly_id
|
65
|
+
cache_key = Digest::MD5.hexdigest "#{self.class.name} #{self.friendly_id}"
|
66
|
+
Rails.cache.write cache_key, self
|
67
|
+
end
|
56
68
|
else
|
57
69
|
false
|
58
70
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cache_money_millionaire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
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: 2013-03-
|
12
|
+
date: 2013-03-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -62,7 +62,7 @@ files:
|
|
62
62
|
- lib/cache_money_millionaire/rails/cache_key_patch.rb
|
63
63
|
- lib/cache_money_millionaire/rails/engine.rb
|
64
64
|
- lib/cache_money_millionaire/version.rb
|
65
|
-
homepage:
|
65
|
+
homepage: https://github.com/johnkoht/cache-money-millionaire
|
66
66
|
licenses:
|
67
67
|
- MIT
|
68
68
|
post_install_message:
|