Increased default expire of cache from 1 day to 7 days.

This commit is contained in:
Martin Edenhofer 2015-06-24 13:33:07 +02:00
parent 7b87bf23af
commit 396cc08c5a

View file

@ -4,7 +4,7 @@ module Cache
delete a cache delete a cache
Cache.delete( 'some_key' ) Cache.delete('some_key')
=end =end
@ -18,9 +18,9 @@ write a cache
Cache.write( Cache.write(
'some_key', 'some_key',
{ :some => { :data => { 'structure' } } }, { some: { data: { 'structure' } } },
{ {
:expires_in => 24.hours, # optional :expires_in => 24.hours, # optional, default 7 days
} }
) )
@ -28,10 +28,10 @@ write a cache
def self.write( key, data, params = {} ) def self.write( key, data, params = {} )
if !params[:expires_in] if !params[:expires_in]
params[:expires_in] = 24.hours params[:expires_in] = 7.days
end end
begin begin
Rails.cache.write( key.to_s, data, params) Rails.cache.write(key.to_s, data, params)
rescue => e rescue => e
Rails.logger.error "NOTICE: #{e.message}" Rails.logger.error "NOTICE: #{e.message}"
end end
@ -41,12 +41,12 @@ write a cache
get a cache get a cache
value = Cache.write( 'some_key' ) value = Cache.write('some_key')
=end =end
def self.get( key ) def self.get( key )
Rails.cache.read( key.to_s ) Rails.cache.read(key.to_s)
end end
=begin =begin
@ -59,7 +59,7 @@ clear whole cache store
def self.clear def self.clear
# workaround, set test cache before clear whole cache, Rails.cache.clear complains about not existing cache dir # 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 Rails.cache.clear
end end