[TYPO3-core] FYI72: enhancements to memcached caching backend
Karsten Dambekalns
karsten at typo3.org
Thu Dec 4 11:41:57 CET 2008
Hi Dmitry.
On 03.12.2008, at 21:30, Dmitry Dulepov wrote:
> Problems:
> 1. memcached backend does not support connections through Unix
> sockets ("unix:///var/run/memcached.sock")
> Solution:
> 1. enable support for Unix sockets (this is official way to do it,
> not a hack!)
Agreed, makes sense.
> Problems:
> 2. if memcached server is unavailable, this fact will be detected
> too late (when using get/set) and nasty error message will be shown
> Solution:
> 2. use "connect" instead of "addServer"
Here we loose failover within the connection pool. Here's what the
docs say about addServer():
--- snip ---
When using this method (as opposed to Memcache::connect() and
Memcache::pconnect()) the network connection is not established until
actually needed. Thus there is no overhead in adding a large number of
servers to the pool, even though they might not all be used.
Failover may occur at any stage in any of the methods, as long as
other servers are available the request the user won't notice. Any
kind of socket or Memcached server level errors (except out-of-memory)
may trigger the failover. Normal client errors such as adding an
existing key will not trigger a failover.
--- snip ---
addServer() accepts unix sockets the same way as connect(), so those
can be combined. It makes sense to look at what happens when a server
is not available, given the fact that an error is counter-productive
to failover. ;)
So the patch could look like this:
> Index: t3lib/cache/backend/class.t3lib_cache_backend_memcached.php
> ===================================================================
> --- t3lib/cache/backend/class.t3lib_cache_backend_memcached.php
> (revision 4519)
> +++ t3lib/cache/backend/class.t3lib_cache_backend_memcached.php
> (working copy)
> @@ -111,8 +111,13 @@
> }
>
> foreach ($this->servers as $serverConf) {
> - $conf = explode(':',$serverConf, 2);
> - $this->memcache->addServer($conf[0], $conf[1]);
> + if (substr($serverConf, 0, 7) == 'unix://') {
> + $this->memcache->addServer($serverConf, 0);
> + }
> + else {
> + $conf = explode(':',$serverConf, 2);
> + $this->memcache->addServer($conf[0], $conf[1]);
> + }
> }
> }
Regards,
Karsten
--
Karsten Dambekalns
Gimme Five!
http://typo3.org/gimmefive
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 304 bytes
Desc: This is a digitally signed message part
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20081204/61830fc7/attachment.pgp
More information about the TYPO3-team-core
mailing list