model-cache 0.1.2 → 0.1.3
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.
- data/lib/model_cache.rb +4 -4
- metadata +1 -1
data/lib/model_cache.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module ModelCache
|
2
2
|
|
3
|
-
DEFAULT_TIME = 12.hours
|
4
|
-
|
3
|
+
DEFAULT_TIME = 12.hours unless const_defined?(:DEFAULT_TIME)
|
4
|
+
NIL_OBJECT = Object.new unless const_defined?(:NIL_OBJECT)
|
5
5
|
|
6
6
|
def self.included(klass)
|
7
7
|
klass.extend ClassMethods
|
@@ -13,7 +13,7 @@ module ModelCache
|
|
13
13
|
|
14
14
|
def self.cache(ckey, time = DEFAULT_TIME, &block)
|
15
15
|
if Rails.configuration.action_controller.perform_caching && (result = CACHE.get(ckey))
|
16
|
-
if result ==
|
16
|
+
if result == NIL_OBJECT
|
17
17
|
nil
|
18
18
|
else
|
19
19
|
result
|
@@ -24,7 +24,7 @@ module ModelCache
|
|
24
24
|
if result
|
25
25
|
CACHE.set(ckey, result, time)
|
26
26
|
else
|
27
|
-
CACHE.set(ckey,
|
27
|
+
CACHE.set(ckey, NIL_OBJECT, time)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
result
|