Files
danbooru/config/initializers/cache_store.rb
evazion dfe2b831a3 cache: replace memcache with redis.
Drop memcache. Use redis for all caching instead.
2019-08-22 23:15:34 -05:00

27 lines
791 B
Ruby

Rails.application.configure do
if Rails.env.test?
cache_config = [:memory_store, { size: 32.megabytes }]
else
cache_config = [
:redis_cache_store,
{
url: Danbooru.config.redis_url,
namespace: nil,
connect_timeout: 30, # default: 20 seconds
write_timeout: 0.2, # default: 1 second
read_timeout: 0.2, # default: 1 second
reconnect_attempts: 0, # default: 0
error_handler: ->(method:, returning:, exception:) {
DanbooruLogger.log(exception, method: method, returning: returning)
}
}
]
end
cache_store = ActiveSupport::Cache.lookup_store(cache_config)
config.cache_store = cache_store
config.action_controller.cache_store = cache_store
Rails.cache = cache_store
end