Skip to content

Instantly share code, notes, and snippets.

View PikachuEXE's full-sized avatar
Pika~Pika~

PikachuEXE PikachuEXE

Pika~Pika~
View GitHub Profile
@PikachuEXE
PikachuEXE / check_for_memcached.rb
Last active December 21, 2015 12:19 — forked from subelsky/check_for_memcached.rb
Use memcached as cache store on development if it is running
# 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