For Programmers: Free Programming Magazines  


Home > Archive > PHP PECL > October 2005 > memcache extension improvements (multiple servers, failover, compress threshold)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author memcache extension improvements (multiple servers, failover, compress threshold)
Mikael Johansson

2005-10-20, 7:02 pm

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/wcm...type=text/plain
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com