lib/model_cache.rb in model-cache-0.2.0 vs lib/model_cache.rb in model-cache-0.2.2
- old
+ new
@@ -24,13 +24,11 @@
result = CACHE.get(ckey.hash.to_s)
if result
cache_hit = true
end
if result == NIL_OBJECT
- nil
- else
- result
+ result = nil
end
else
raise "CACHE object not configured #{CACHE.inspect}!"
end
end
@@ -55,12 +53,13 @@
end
module ClassMethods
def cache_method(*args)
+ opts = args.extract_options!
args.each do |sym|
- cache_method_for_time(sym, DEFAULT_TIME)
+ cache_method_for_time(sym, (opts[:time] || DEFAULT_TIME))
end
end
def cache_method_for_time(sym, time)
alias_method :"__noncached_#{sym}", sym
@@ -72,10 +71,10 @@
end
define_method :"__is_cached_#{sym}?" do |*args|
ckey = [self.cache_key, sym, *args]
!!( Rails.configuration.action_controller.perform_caching && CACHE.get(ckey) )
end
- define_method :"__uncache_#{sym}" do |*args|
+ define_method :"__flush_#{sym}" do |*args|
ckey = [self.cache_key, sym, *args]
CACHE.delete(ckey)
end
end
end
\ No newline at end of file