Permalink
Browse files

make partial rendering resistant to losing a memcache key

  • Loading branch information...
1 parent 143e066 commit 52b2bf3653b0f572758d641063135e4560d69c43 @jdwyah jdwyah committed Jun 25, 2012
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/patella/patella.rb
View
@@ -15,9 +15,13 @@ def patella_key(symbol, args)
def self.from_key(cache_key)
- val = JSON.parse(Rails.cache.read(cache_key))
-
- PatellaResult.new(val['result'], val['promise'], cache_key)
+ val = Rails.cache.read(cache_key)
+ if val.blank?
+ PatellaResult.new({}, true, cache_key)
+ else
+ val = JSON.parse(val) unless val.blank?
+ PatellaResult.new(val['result'], val['promise'], cache_key)
+ end
end
module ClassMethods

0 comments on commit 52b2bf3

Please sign in to comment.