Skip to content

Commit

Permalink
Fixed expiration bug
Browse files Browse the repository at this point in the history
  • Loading branch information
cykod committed Mar 18, 2010
1 parent 77096da commit 602b3b1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions app/controllers/paragraph_renderer.rb
Expand Up @@ -620,10 +620,9 @@ def delayed_cache_fetch(obj,method,args={},display_string=nil,options={ })
display_string = "#{paragraph.id}_#{display_string}"
result = nil

result, expiration = DataCache.get_remote("Paragraph",paragraph.id.to_s,display_string)
result, expired_at = DataCache.get_remote("Paragraph",paragraph.id.to_s,display_string)
now = Time.now

if result && expiration && expiration > now
if result && expired_at && expired_at > now
return DefaultsHashObject.new(result)
end

Expand All @@ -641,7 +640,7 @@ def delayed_cache_fetch(obj,method,args={},display_string=nil,options={ })

# if we don't have an expired or we are expired and not in the editor
# kick of the worker and put the current results in the cache to be updated
if !result || !expiration || expiration <= now
if !result || !expiration || expired_at <= now
DataCache.put_remote("Paragraph",paragraph.id.to_s,display_string,[ result, now + expiration.to_i.seconds ])
logger.warn("Running Delayed worker: #{display_string}")
if obj.is_a?(Class)
Expand Down

0 comments on commit 602b3b1

Please sign in to comment.