Improved error handling on many concurrent cache file writes/deletes. Do not raise exemption if write was not successfully.

This commit is contained in:
Martin Edenhofer 2014-11-06 21:44:13 +01:00
parent 450984719c
commit ba75b4a0de

View file

@ -8,7 +8,11 @@ module Cache
params[:expires_in] = 24.hours
end
# puts 'Cache.write: ' + key.to_s
Rails.cache.write( key.to_s, data, params)
begin
Rails.cache.write( key.to_s, data, params)
rescue Exception => e
puts "NOTICE: #{e.message}"
end
end
def self.get( key )
# puts 'Cache.get: ' + key.to_s
@ -17,7 +21,7 @@ module Cache
def self.clear
# puts 'Cache.clear...'
# workaround, set test cache before clear whole cache, Rails.cache.clear complains about not existing cache dir
Cache.write('test',1 )
Cache.write( 'test', 1 )
Rails.cache.clear
end