class Memcached < Formula desc "High performance, distributed memory object caching system" homepage "https://memcached.org/" url "https://www.memcached.org/files/memcached-1.5.16.tar.gz" sha256 "45a22c890dc1edb27db567fb4c9c25b91bfd578477c08c5fb10dca93cc62cc5a" bottle do cellar :any sha256 "5deff247a1bbbdecd0e22ed534a4de8d57fc5a9d5c7dde08763a366c8783b54a" => :mojave sha256 "ef7043afc7f9af67793fb428e00ad392bbd5bc028821974dfc09349215a3aa2a" => :high_sierra sha256 "4089234077cad271e86e0dbc7c18d7ce0276c47e4fa6d926002d33909e817927" => :sierra end depends_on "libevent" conflicts_with "mysql-cluster", :because => "both install `bin/memcached`" def install system "./configure", "--prefix=#{prefix}", "--disable-coverage" system "make", "install" end plist_options :manual => "#{HOMEBREW_PREFIX}/opt/memcached/bin/memcached" def plist; <<~EOS Label #{plist_name} KeepAlive ProgramArguments #{opt_bin}/memcached -l localhost RunAtLoad WorkingDirectory #{HOMEBREW_PREFIX} EOS end test do pidfile = testpath/"memcached.pid" # Assumes port 11211 is not already taken system bin/"memcached", "--listen=localhost:11211", "--daemon", "--pidfile=#{pidfile}" sleep 1 assert_predicate pidfile, :exist?, "Failed to start memcached daemon" pid = (testpath/"memcached.pid").read.chomp.to_i Process.kill "TERM", pid end end