BlockCache
Simply, cache ruby block data in mongo.
usage:
class TwitterPoller
include BlockCache
def twitter_latest
results = cache_overwrite_by request.path do
# your unreliable twitter call goes here...
end
render :json => results.to_json
end
end
To use wrap your flimsy external service call with this block and conditionally raise an error if failure occurs. Most gems will handle this for you but if the block raises, then previous value will be returned and no errors raised.