This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use a different cache store based on memcached is running or not | |
begin | |
# check if memcached is running; if it is, use that instead of the default memory cache | |
Timeout.timeout(0.5) { TCPSocket.open("localhost", 11211) { } } | |
config.cache_store = :dalli_store, %w(localhost:11211), {namespace: Rails.application.class.parent_name, expires_in: 1.day, compress: true} | |
$stderr.puts "Using memcached on localhost:11211" | |
rescue StandardError | |
$stderr.puts "memcached not running, caching to memory" | |
end |