Created
June 2, 2011 14:54
-
-
Save avargas/1004594 to your computer and use it in GitHub Desktop.
PHP Memcached failover
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$mem = new Memcached("pool"); | |
$mem->setOption(Memcached::OPT_BINARY_PROTOCOL, true); | |
$mem->setOption(Memcached::OPT_DISTRIBUTION, Memcached::DISTRIBUTION_CONSISTENT); | |
$mem->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true); | |
$mem->setOption(Memcached::OPT_NO_BLOCK, true); | |
$mem->setOption(Memcached::OPT_SERVER_FAILURE_LIMIT, 1); | |
$mem->setOption(Memcached::OPT_RETRY_TIMEOUT, 30); | |
$mem->setOption(29, 2); | |
if (!count($mem->getServerList())) { | |
$mem->addServers(array( | |
array('127.0.0.1', 10001), | |
array('127.0.0.1', 10002), | |
array('127.0.0.1', 10003), | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment