memcached unix socket, first draft
Peter Molnar hello@petermolnar.eu
Thu, 07 Nov 2013 21:11:12 +0000
2 files changed,
17 insertions(+),
13 deletions(-)
M
wp-ffpc-backend.php
→
wp-ffpc-backend.php
@@ -387,14 +387,13 @@
$separator = strpos( $sstring , self::port_separator ); $host = substr( $sstring, 0, $separator ); $port = substr( $sstring, $separator + 1 ); + // unix socket failsafe + if ( empty ($port) ) $port = 0; - /* IP server */ - if ( !empty ( $host ) && !empty($port) && is_numeric($port) ) { - $this->options['servers'][$sstring] = array ( - 'host' => $host, - 'port' => $port - ); - } + $this->options['servers'][$sstring] = array ( + 'host' => $host, + 'port' => $port + ); } }@@ -692,11 +691,16 @@ }
/* adding servers */ foreach ( $this->options['servers'] as $server_id => $server ) { - /* reset server status to unknown */ if ( $this->options['persistent'] == '1' ) - $this->status[$server_id] = $this->connection->pconnect ( $server['host'] , $server['port'] ); + $conn = 'pconnect'; + else + $conn = 'connect'; + + /* in case of unix socket */ + if ( $server['port'] === 0 ) + $this->status[$server_id] = $this->connection->$conn ( 'unix:/' . $server['host'] ); else - $this->status[$server_id] = $this->connection->connect ( $server['host'] , $server['port'] ); + $this->status[$server_id] = $this->connection->$conn ( $server['host'] , $server['port'] ); $this->log ( $server_id . __translate__(" added, persistent mode: ", $this->plugin_constant ) . $this->options['persistent'] ); }
M
wp-ffpc-class.php
→
wp-ffpc-class.php
@@ -250,9 +250,8 @@ }
/** * uninstall hook function, to be extended - * [TODO] static abstraction is not allowed in PHP; how to do this? */ - static public function plugin_uninstall( $delete_options = true ) { + public function plugin_uninstall( $delete_options = true ) { /* delete advanced-cache.php file */ unlink ( $this->acache );@@ -606,7 +605,8 @@ <label for="hosts"><?php _e('Hosts', $this->plugin_constant); ?></label>
</dt> <dd> <input type="text" name="hosts" id="hosts" value="<?php echo $this->options['hosts']; ?>" /> - <span class="description"><?php _e('List all valid like host:port,host:port,... <br />No spaces are allowed, please stick to use ":" for separating host and port and "," for separating entries. Do not add trailing ",".', $this->plugin_constant); ?></span> + <span class="description"> + <?php _e('List of memcached backends, with the following syntax: <br />- in case of TCP based connections, list the servers as host1:port1,host2:port2,... . Do not add trailing , and always separate host and port with : .<br />- in2.0.0b1 case using unix sockets with the Memcache driver: unix:// ', $this->plugin_constant); ?></span> </dd> <dt> <label for="persistent"><?php _e('Persistent memcache connections', $this->plugin_constant); ?></label>