memcache extension improvements (multiple servers, failover, compress threshold)

From: Date: Thu, 20 Oct 2005 21:10:07 +0000
Subject: memcache extension improvements (multiple servers, failover, compress threshold)
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-3131@lists.php.net to get a copy of this message
Code available at http://www.synd.info/extensions/memcache/ Load is distributed to backend servers based on weight, key hashing is done using the new-style crc32 method compatible with other client API's. Failover is transparent; as long as alternate backends exist, client code won't know (other that an E_NOTICE). Failed servers are marked as failed and will be reconnected in X seconds (default 15). 3 new methods: Memcache::addServer(host, port = 11211, persistent = true, weight = 1, timeout = 1, retry_interval = 15) : bool * Persistent connections by default as recommended in the protocol spec * Weight is relative the weight of other servers (p = weight/SUM(weights) when selecting a server given a key) * Socket timeout as in connect()/pconnect() * Retry interval is the number of seconds to wait before attemting to reconnect a failed backend Memcache::getExtendedStats() : array("hostname:port" => array(stats), "failedhost:port" => FALSE, ...) * Returns regular server stats for each backend Memcache::setCompressThreshold(bytes, min_savings = 0.20) : bool * Attempt to compress values automatically if strlen > threshold * Minimum default savings of 20% to actually store compressed Corresponding functions memcache_add_server(handle, ...) memcache_get_extended_stats(handle) memcache_set_compress_threshold(handle, ...) I have been in contact with the current maintainer Anthony Dovgal, who is positive to the changes. More feedback from other users and help with testing would be appreciated. The tests/ folder contain some new unit tests (019-028.phpt) //Mikael Memcache protocol spec http://cvs.danga.com/browse.cgi/wcmtools/memcached/doc/protocol.txt?rev=HEAD&content-type=text/plain

« previous php.pecl.dev (#3131) next »