initializers/z_dalli.rb: initialize Rails.cache.
This commit is contained in:
@@ -1,24 +1,26 @@
|
|||||||
unless defined?(MEMCACHE)
|
Rails.application.configure do
|
||||||
MEMCACHE = Dalli::Client.new(Danbooru.config.memcached_servers, :namespace => Danbooru.config.app_name.gsub(/[^A-Za-z0-9]/, "_"))
|
begin
|
||||||
end
|
if Rails.env.test?
|
||||||
|
config.cache_store = :memory_store, { size: 32.megabytes }
|
||||||
|
Rails.cache = ActiveSupport::Cache.lookup_store(Rails.application.config.cache_store)
|
||||||
|
else
|
||||||
|
config.cache_store = :dalli_store, Danbooru.config.memcached_servers, { namespace: Danbooru.config.safe_app_name }
|
||||||
|
Rails.cache = ActiveSupport::Cache.lookup_store(Rails.application.config.cache_store)
|
||||||
|
|
||||||
begin
|
Rails.cache.dalli.alive!
|
||||||
MEMCACHE.get("x")
|
end
|
||||||
rescue Dalli::RingError => e
|
rescue Dalli::RingError => e
|
||||||
puts "-" * 40
|
puts "-" * 40
|
||||||
puts "WARNING! MEMCACHE SERVER NOT FOUND! You will experience performance degradation."
|
puts "WARNING! MEMCACHE SERVER NOT FOUND! You will experience performance degradation."
|
||||||
puts e.to_s
|
puts e.to_s
|
||||||
puts "-- BEGIN STACKTRACE --"
|
puts "-- BEGIN STACKTRACE --"
|
||||||
e.backtrace.each do |line|
|
e.backtrace.each do |line|
|
||||||
puts line
|
puts line
|
||||||
end
|
end
|
||||||
puts "-- END STACKTRACE --"
|
puts "-- END STACKTRACE --"
|
||||||
puts "-" * 40
|
puts "-" * 40
|
||||||
MEMCACHE = MemcacheMock.new
|
|
||||||
end
|
|
||||||
|
|
||||||
if Rails.env.production?
|
config.cache_store = :memory_store, { size: 32.megabytes }
|
||||||
Rails.application.configure do
|
Rails.cache = ActiveSupport::Cache.lookup_store(Rails.application.config.cache_store)
|
||||||
config.cache_store = :dalli_store, Danbooru.config.memcached_servers
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user