cache: replace memcache with redis.
Drop memcache. Use redis for all caching instead.
This commit is contained in:
26
config/initializers/cache_store.rb
Normal file
26
config/initializers/cache_store.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
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
|
||||
Reference in New Issue
Block a user