Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Use memcached as cache store on development if it is running
# Use a different cache store based on memcached is running or not
# check if memcached is running; if it is, use that instead of the default memory cache
Timeout.timeout(0.5) {"localhost", 11211) { } }
config.cache_store = :dalli_store, %w(localhost:11211), {namespace: Rails.application.class.parent_name, expires_in:, compress: true}
$stderr.puts "Using memcached on localhost:11211"
rescue StandardError
$stderr.puts "memcached not running, caching to memory"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment