version 0.6.1
git-svn-id: http://plugins.svn.wordpress.org/wp-ffpc/trunk@677998 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
parent
c41f847093
commit
4310614a3c
3 changed files with 72 additions and 25 deletions
|
@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
||||||
Tags: cache, APC, memcache, memcached, page cache, full page cache, nginx
|
Tags: cache, APC, memcache, memcached, page cache, full page cache, nginx
|
||||||
Requires at least: 3.0
|
Requires at least: 3.0
|
||||||
Tested up to: 3.5.1
|
Tested up to: 3.5.1
|
||||||
Stable tag: 0.5.1
|
Stable tag: 0.6.1
|
||||||
|
|
||||||
Store WordPress pages in memcached and serve them with nginx - unbeatable speed!
|
Store WordPress pages in memcached and serve them with nginx - unbeatable speed!
|
||||||
|
|
||||||
|
@ -56,8 +56,13 @@ You have to remove the default yum package, named `php-pecl-memcache` and instal
|
||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
|
= 0.6.1 =
|
||||||
|
*2013.03.08*
|
||||||
|
|
||||||
|
* refactored & corrected backend status check for memcached driver
|
||||||
|
|
||||||
= 0.6 =
|
= 0.6 =
|
||||||
*development branch*
|
*2013.03.08*
|
||||||
|
|
||||||
* true WordPress Network support:
|
* true WordPress Network support:
|
||||||
* if enabled network-wide, settings will be the same for every site
|
* if enabled network-wide, settings will be the same for every site
|
||||||
|
|
|
@ -56,17 +56,20 @@ function wp_ffpc_init( $wp_ffpc_config ) {
|
||||||
if (!class_exists('Memcache'))
|
if (!class_exists('Memcache'))
|
||||||
return false;
|
return false;
|
||||||
if ( $wp_ffpc_backend == NULL )
|
if ( $wp_ffpc_backend == NULL )
|
||||||
{
|
|
||||||
$wp_ffpc_backend = new Memcache();
|
$wp_ffpc_backend = new Memcache();
|
||||||
|
|
||||||
foreach ( $wp_ffpc_config['servers'] as $server_id => $server ) {
|
foreach ( $wp_ffpc_config['servers'] as $server_id => $server ) {
|
||||||
$wp_ffpc_backend_status[$server_id] = $wp_ffpc_backend->connect( $server['host'] , $server['port'] );
|
$wp_ffpc_backend_status[$server_id] = $wp_ffpc_backend->connect( $server['host'] , $server['port'] );
|
||||||
|
|
||||||
$wp_ffpc_config['persistent'] = ( $wp_ffpc_config['persistent'] == '1' ) ? true : false;
|
$wp_ffpc_config['persistent'] = ( $wp_ffpc_config['persistent'] == '1' ) ? true : false;
|
||||||
if ( $wp_ffpc_backend_status[$server_id] )
|
if ( $wp_ffpc_backend_status[$server_id] )
|
||||||
|
{
|
||||||
|
$wp_ffpc_backend_status[$server_id] = true;
|
||||||
$wp_ffpc_backend->addServer( $server['host'] , $server['port'], $wp_ffpc_config['persistent'] );
|
$wp_ffpc_backend->addServer( $server['host'] , $server['port'], $wp_ffpc_config['persistent'] );
|
||||||
wp_ffpc_log ( "server " . $server_id . " added, persistent mode: " . $wp_ffpc_config['persistent'] );
|
wp_ffpc_log ( "server " . $server_id . " added, persistent mode: " . $wp_ffpc_config['persistent'] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return $wp_ffpc_backend_status;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* in case of Memcached */
|
/* in case of Memcached */
|
||||||
|
@ -74,34 +77,62 @@ function wp_ffpc_init( $wp_ffpc_config ) {
|
||||||
/* Memcached class does not exist, Memcached extension is not available */
|
/* Memcached class does not exist, Memcached extension is not available */
|
||||||
if (!class_exists('Memcached'))
|
if (!class_exists('Memcached'))
|
||||||
return false;
|
return false;
|
||||||
|
/* check is there's no backend connection yet */
|
||||||
if ( $wp_ffpc_backend == NULL )
|
if ( $wp_ffpc_backend == NULL )
|
||||||
{
|
{
|
||||||
|
/* persistent backend needs an identifier */
|
||||||
if ( $wp_ffpc_config['persistent'] == '1' )
|
if ( $wp_ffpc_config['persistent'] == '1' )
|
||||||
$wp_ffpc_backend = new Memcached( WP_FFPC_PARAM );
|
$wp_ffpc_backend = new Memcached( WP_FFPC_PARAM );
|
||||||
else
|
else
|
||||||
$wp_ffpc_backend = new Memcached();
|
$wp_ffpc_backend = new Memcached();
|
||||||
|
|
||||||
|
/* use binary and not compressed format, good for nginx and still fast */
|
||||||
$wp_ffpc_backend->setOption( Memcached::OPT_COMPRESSION , false );
|
$wp_ffpc_backend->setOption( Memcached::OPT_COMPRESSION , false );
|
||||||
$wp_ffpc_backend->setOption( Memcached::OPT_BINARY_PROTOCOL , true );
|
$wp_ffpc_backend->setOption( Memcached::OPT_BINARY_PROTOCOL , true );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check if we already have list of servers, only add server if it's not already connected */
|
||||||
$wp_ffpc_serverlist = $wp_ffpc_backend->getServerList();
|
$wp_ffpc_serverlist = $wp_ffpc_backend->getServerList();
|
||||||
|
|
||||||
if ( empty ( $wp_ffpc_serverlist ) )
|
/* create check array if backend servers are already connected */
|
||||||
$wp_ffpc_backend->addServers( $wp_ffpc_config['servers'] );
|
if ( !empty ( $wp_ffpc_serverlist ) )
|
||||||
wp_ffpc_log ( "servers added, persistent mode: " . $wp_ffpc_config['persistent'] );
|
foreach ( $wp_ffpc_serverlist as $server )
|
||||||
}
|
$wp_ffpc_serverlist_[ $server['host'] . ":" . $server['port'] ] = true;
|
||||||
$wp_ffpc_backend_report = $wp_ffpc_backend->getStats();
|
|
||||||
|
|
||||||
|
/* reset all configured server status to unknown */
|
||||||
|
foreach ( $wp_ffpc_config['servers'] as $server_id => $server )
|
||||||
|
$wp_ffpc_backend_status[$server_id] = -1;
|
||||||
|
|
||||||
|
/* if there's no server to add, don't add them */
|
||||||
|
if ( empty ( $wp_ffpc_config['servers'] ) )
|
||||||
|
{
|
||||||
|
wp_ffpc_log ( "not adding empty set of servers, please check your settings!" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
foreach ( $wp_ffpc_config['servers'] as $server_id => $server ) {
|
foreach ( $wp_ffpc_config['servers'] as $server_id => $server ) {
|
||||||
|
if (!@array_key_exists($server_id , $wp_ffpc_serverlist_ ))
|
||||||
|
{
|
||||||
|
$wp_ffpc_backend->addServer( $server['host'], $server['port'] );
|
||||||
|
wp_ffpc_log ( "server ". $server_id ." added, persistent mode: " . $wp_ffpc_config['persistent'] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* server status will be calculated by getting server stats */
|
||||||
|
$wp_ffpc_backend_report = $wp_ffpc_backend->getStats();
|
||||||
|
foreach ( $wp_ffpc_backend_report as $server_id => $server ) {
|
||||||
$wp_ffpc_backend_status[$server_id] = false;
|
$wp_ffpc_backend_status[$server_id] = false;
|
||||||
if ( array_key_exists( $server_id, $wp_ffpc_backend_report ) && $wp_ffpc_backend_report[ $server_id ]['pid'] != -1 ) {
|
/* if server uptime is not empty, it's most probably up & running */
|
||||||
|
if ( !empty($server['uptime']) )
|
||||||
$wp_ffpc_backend_status[$server_id] = true;
|
$wp_ffpc_backend_status[$server_id] = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* cache type is invalid */
|
/* cache type is invalid */
|
||||||
default:
|
default:
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( empty ( $wp_ffpc_backend_status ) ? false : $wp_ffpc_backend_status );
|
return ( empty ( $wp_ffpc_backend_status ) ? false : $wp_ffpc_backend_status );
|
||||||
|
|
21
wp-ffpc.php
21
wp-ffpc.php
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
Plugin Name: WP-FFPC
|
Plugin Name: WP-FFPC
|
||||||
Version: 0.6
|
Version: 0.6.1
|
||||||
Plugin URI: http://petermolnar.eu/wordpress/wp-ffpc
|
Plugin URI: http://petermolnar.eu/wordpress/wp-ffpc
|
||||||
Description: Fast Full Page Cache, backend can be memcached or APC
|
Description: Fast Full Page Cache, backend can be memcached or APC
|
||||||
Author: Peter Molnar
|
Author: Peter Molnar
|
||||||
|
@ -66,7 +66,7 @@ define ( 'WP_FFPC_SERVER_SEPARATOR', ':' );
|
||||||
define ( 'WP_FFPC_DONATION_LINK', 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XU3DG7LLA76WC' );
|
define ( 'WP_FFPC_DONATION_LINK', 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XU3DG7LLA76WC' );
|
||||||
define ( 'WP_FFPC_FILE' , plugin_basename(__FILE__) );
|
define ( 'WP_FFPC_FILE' , plugin_basename(__FILE__) );
|
||||||
define ( 'WP_FFPC_PLUGIN' , 'wp-ffpc/wp-ffpc.php' );
|
define ( 'WP_FFPC_PLUGIN' , 'wp-ffpc/wp-ffpc.php' );
|
||||||
define ( 'WP_FFPC_VERSION' , '0.6' );
|
define ( 'WP_FFPC_VERSION' , '0.6.1' );
|
||||||
|
|
||||||
if ( ! function_exists( 'is_plugin_active_for_network' ) )
|
if ( ! function_exists( 'is_plugin_active_for_network' ) )
|
||||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||||
|
@ -163,6 +163,13 @@ if (!class_exists('WPFFPC')) {
|
||||||
/* not network, will be in simple admin menu */
|
/* not network, will be in simple admin menu */
|
||||||
else
|
else
|
||||||
add_action('admin_menu', array( $this , 'admin_init') );
|
add_action('admin_menu', array( $this , 'admin_init') );
|
||||||
|
|
||||||
|
if ( $this->all_options['version'] < WP_FFPC_VERSION ) {
|
||||||
|
$this->save_settings ();
|
||||||
|
if ( @file_exists( WP_FFPC_ACACHE_MAIN_FILE )) {
|
||||||
|
$this->generate_config();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -291,8 +298,12 @@ if (!class_exists('WPFFPC')) {
|
||||||
/* we need to go through all servers */
|
/* we need to go through all servers */
|
||||||
foreach ( $this->options['servers'] as $server_string => $server ) {
|
foreach ( $this->options['servers'] as $server_string => $server ) {
|
||||||
echo $server['host'] . ":" . $server['port'] ." => ";
|
echo $server['host'] . ":" . $server['port'] ." => ";
|
||||||
$server_status = ( empty($init) || $init[$server_string] == 0 ) ? '<span class="error-msg">down</span>' : '<span class="ok-msg">up & running</span>' ;
|
if ( is_array($init) && $init[$server_string] === false )
|
||||||
echo $server_status ."<br />\n";
|
_e ( '<span class="error-msg">down</span><br />', WP_FFPC_PARAM );
|
||||||
|
elseif ( is_array($init) && $init[$server_string] === true )
|
||||||
|
_e ( '<span class="ok-msg">up & running</span><br />', WP_FFPC_PARAM );
|
||||||
|
else
|
||||||
|
_e ( '<span class="error-msg">unknown, please try re-saving settings!</span><br />', WP_FFPC_PARAM );
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
|
@ -686,7 +697,7 @@ if (!class_exists('WPFFPC')) {
|
||||||
'prefix_data' =>'data-',
|
'prefix_data' =>'data-',
|
||||||
'charset' => 'utf-8',
|
'charset' => 'utf-8',
|
||||||
'pingback_status'=> false,
|
'pingback_status'=> false,
|
||||||
'debug' => true,
|
'debug' => false,
|
||||||
'syslog' => false,
|
'syslog' => false,
|
||||||
'cache_type' => 'memcached',
|
'cache_type' => 'memcached',
|
||||||
'cache_loggedin' => false,
|
'cache_loggedin' => false,
|
||||||
|
|
Loading…
Reference in a new issue