adding SASL auth fields & support for memcached

This commit is contained in:
Peter Molnar 2014-06-02 16:02:13 +01:00
parent 6e4d474796
commit 9804bc515e
3 changed files with 32 additions and 1 deletions

View file

@ -735,6 +735,10 @@ if (!class_exists('WP_FFPC_Backend')) {
/* use binary and not compressed format, good for nginx and still fast */
$this->connection->setOption( Memcached::OPT_COMPRESSION , false );
$this->connection->setOption( Memcached::OPT_BINARY_PROTOCOL , true );
if ( version_compare( phpversion( 'memcached' ) , '2.0.0', '>=' ) && ini_get( 'memcached.use_sasl' ) == 1 ) {
$this->connection->setSaslAuthData ( $this->options['authuser'], $this->options['authpass']);
}
}
/* check if initialization was success or not */

View file

@ -631,6 +631,31 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
<input type="checkbox" name="persistent" id="persistent" value="1" <?php checked($this->options['persistent'],true); ?> />
<span class="description"><?php _e('Make all memcache(d) connections persistent. Be careful with this setting, always test the outcome.', $this->plugin_constant); ?></span>
</dd>
<?php
if ( strstr ( $this->options['cache_type'], 'memcached') && extension_loaded ( 'memcached' ) && version_compare( phpversion( 'memcached' ) , '2.0.0', '>=' ) ) { ?>
<?php
if ( ! ini_get('memcached.use_sasl') && ( !empty( $this->options['authuser'] ) || !empty( $this->options['authpass'] ) ) ) { ?>
<div class="error"><p><strong><?php _e( 'WARNING: you\'ve entered username and/or password for memcached authentication ( or your browser\'s autocomplete did ) which will not work unless you enable memcached sasl in the PHP settings: add `memcached.use_sasl=1` to php.ini' , $this->plugin_constant ) ?></strong></p></div>
<?php } ?>
<dt>
<label for="authuser"><?php _e('Authentication: username', $this->plugin_constant); ?></label>
</dt>
<dd>
<input type="text" name="authuser" id="authuser" value="<?php echo $this->options['authuser']; ?>" />
<span class="description">
<?php _e('Username for authentication with memcached backends', $this->plugin_constant); ?></span>
</dd>
<dt>
<label for="authpass"><?php _e('Authentication: password', $this->plugin_constant); ?></label>
</dt>
<dd>
<input type="password" name="authpass" id="authpass" value="<?php echo $this->options['authpass']; ?>" />
<span class="description">
<?php _e('Password for authentication with memcached backends - WARNING, the password will be stored plain-text since it needs to be used!', $this->plugin_constant); ?></span>
</dd>
<?php } ?>
</dl>
</fieldset>

View file

@ -29,6 +29,8 @@ include_once ( 'wp-ffpc-class.php' );
$wp_ffpc_defaults = array (
'hosts'=>'127.0.0.1:11211',
'authpass'=>'',
'authuser'=>'',
'expire'=>300,
'invalidation_method'=>0,
'prefix_meta' =>'meta-',
@ -51,6 +53,6 @@ $wp_ffpc_defaults = array (
'comments_invalidate' => true,
);
$wp_ffpc = new WP_FFPC ( 'wp-ffpc', '1.4.0', 'WP-FFPC', $wp_ffpc_defaults, 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XU3DG7LLA76WC' );
$wp_ffpc = new WP_FFPC ( 'wp-ffpc', '1.6.0', 'WP-FFPC', $wp_ffpc_defaults, 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XU3DG7LLA76WC' );
?>