Commit 91226c8bc828c21cc28fb65b21f6c218ddf869bc

Authored by Moises Machado
Committed by Antonio Terceiro
1 parent ef9e7758

ActionItem1163: fragment.to_time for timeouts and is expired if theres only the timout fragment

vendor/plugins/timed_cached_fragment/lib/timed_cache_fragment.rb
@@ -20,6 +20,7 @@ module ActionController @@ -20,6 +20,7 @@ module ActionController
20 #checks to see if a cache has fully expired 20 #checks to see if a cache has fully expired
21 def is_cache_expired?(name, is_key = false) 21 def is_cache_expired?(name, is_key = false)
22 key = is_key ? name : fragment_cache_key(name) 22 key = is_key ? name : fragment_cache_key(name)
  23 + return true unless read_fragment(key)
23 timeout = get_timeout(key) 24 timeout = get_timeout(key)
24 return (!timeout) || (timeout < Time.now) 25 return (!timeout) || (timeout < Time.now)
25 end 26 end
@@ -43,7 +44,8 @@ module ActionController @@ -43,7 +44,8 @@ module ActionController
43 expire_fragment('timeout:' + key) 44 expire_fragment('timeout:' + key)
44 end 45 end
45 def get_timeout(key) 46 def get_timeout(key)
46 - read_fragment('timeout:' + key) 47 + frag = read_fragment('timeout:' + key)
  48 + frag ? frag.to_time : nil
47 end 49 end
48 def set_timeout(key, value) 50 def set_timeout(key, value)
49 write_fragment('timeout:' + key, value) 51 write_fragment('timeout:' + key, value)