Last active
September 12, 2017 15:32
-
-
Save elmariachi111/5637669a028c29e3973a to your computer and use it in GitHub Desktop.
Symfony2 Memcached settings for persistent connections
This file contains 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 | |
namespace Acme\CoreBundle\Classes\Cache; | |
class AcmeMemcached extends \Memcached { | |
function __construct($persistent_id) | |
{ | |
parent::__construct($persistent_id); | |
} | |
/** | |
* prevent adding of new servers. We're persistent! | |
*/ | |
public function addServers(array $servers) | |
{ | |
if (0 == count($this->getServerList())) { | |
parent::addServers($servers); | |
} | |
} | |
} |
This file contains 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
services: | |
memcache.servers: | |
class: Acme\CoreBundle\Classes\Cache\AcmeMemcached | |
arguments: [ "acme_mc" ] #persistent id | |
calls: | |
- [ addServers, [ [ ["10.0.0.1",11211, 50 ], ["10.0.0.2",11211,25], ["10.0.0.3",11211,25] ] ] ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've added the method for addServer as well - see my Gist based on this one. https://gist.github.com/benr77/258e42642b4632d5a826#file-memcachedwrapper-php