class Memcached < Formula desc "High performance, distributed memory object caching system" homepage "https://memcached.org/" url "https://www.memcached.org/files/memcached-1.5.7.tar.gz" sha256 "5bb706a8fc7ae7461a6788eaddd85e4a4e84e952d3a80c21926342c2838f4e46" bottle do cellar :any sha256 "acd08eb0c4e2b4237364123faade971a049f09d92fd1c0221867fb009705d671" => :high_sierra sha256 "88f2db94e693718d392b3bf6a2433a64453fd2f949c911956125e47a7222ceed" => :sierra sha256 "80c5d28051f3e6ee6b3033e22ad9e6aa9f6f174077ecf4752a4d38e082470a17" => :el_capitan end option "with-sasl", "Enable SASL support -- disables ASCII protocol!" option "with-sasl-pwdb", "Enable SASL with memcached's own plain text password db support -- disables ASCII protocol!" depends_on "libevent" deprecated_option "enable-sasl" => "with-sasl" deprecated_option "enable-sasl-pwdb" => "with-sasl-pwdb" conflicts_with "mysql-cluster", :because => "both install `bin/memcached`" def install args = ["--prefix=#{prefix}", "--disable-coverage"] args << "--enable-sasl" if build.with? "sasl" args << "--enable-sasl-pwdb" if build.with? "sasl-pwdb" system "./configure", *args 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