Skip to content

Instantly share code, notes, and snippets.

@subelsky
Created July 23, 2009 20:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save subelsky/153560 to your computer and use it in GitHub Desktop.
Save subelsky/153560 to your computer and use it in GitHub Desktop.
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 = :mem_cache_store, %w(localhost:11211), { :namespace => 'OI', :timeout => 60 }
$stderr.puts "Using memcached on localhost:11211"
rescue StandardError
config.cache_store = nil
$stderr.puts "memcached not running, caching to memory"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment