Permalink
Browse files

Only set expire option if ttl is present

  • Loading branch information...
1 parent 7bf91ca commit b93ba9c38072e81f77f09c6abe9069045e549607 @ydkn committed Nov 27, 2011
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/cacheable.rb
View
@@ -61,7 +61,7 @@ def cache method, options={}
method = method.to_s
method_uncached = "__uncached_#{method.to_s}"
- ttl = options.key?(:ttl) ? options[:ttl].to_i : 10
+ ttl = options.key?(:ttl) ? options[:ttl].to_i : nil
class_eval("alias :#{method_uncached} :#{method}")
class_eval("private :#{method_uncached}")
@@ -71,7 +71,10 @@ def cache method, options={}
begin
cache_key = Cacheable.cache_key self, method, args
- return_value = Rails.cache.fetch cache_key, :expires_in => ttl.seconds do
+ options = {}
+ options[:expires_in] = ttl if ttl
+
+ return_value = Rails.cache.fetch cache_key, options do
cache_value = nil
begin
v = send method_uncached.to_sym, *args

0 comments on commit b93ba9c

Please sign in to comment.