Skip to content
Snippets Groups Projects
Commit a1140cb2 authored by Taico Aerts's avatar Taico Aerts
Browse files

Fix caching

The namespaced env cache needs to be recreated after forking. With the
old method of changing the Rails cache, this was not happening
correctly.
parent 00235ef7
Branches
Tags
1 merge request!24Release 22-09-2022
......@@ -26,6 +26,8 @@ module Qpixel
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.1
config.autoload_paths << Rails.root.join('lib')
config.exceptions_app = -> (env) do
ErrorsController.action(:error).call(env)
end
......
require 'active_support/core_ext/integer/time'
require 'namespaced_env_cache'
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
......@@ -18,9 +19,11 @@ Rails.application.configure do
# Set the cache store to the redis that was configured in the database.yml
processed = ERB.new(File.read(Rails.root.join('config', 'database.yml'))).result(binding)
redis_config = YAML.safe_load(processed, [], [], true)["redis_#{Rails.env}"]
config.cache_store = :redis_cache_store, {
config.cache_store = QPixel::NamespacedEnvCache.new(
ActiveSupport::Cache::RedisCacheStore.new(
url: "redis://#{redis_config['host']}:#{redis_config['port']}"
}
)
)
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
......
require 'active_support/core_ext/integer/time'
require 'namespaced_env_cache'
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
......@@ -58,7 +59,9 @@ Rails.application.configure do
config.log_tags = [ :subdomain, :uuid ]
# Use a different cache store in production.
config.cache_store = :redis_cache_store, { url: 'redis://localhost:6379/1' }
config.cache_store = QPixel::NamespacedEnvCache.new(
RedisCacheStore.new(url: 'redis://localhost:6379/1')
)
# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque
......
......@@ -77,5 +77,3 @@ module QPixel
end
end
end
Rails.cache = QPixel::NamespacedEnvCache.new(Rails.cache)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment