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
|
||||
Requires at least: 3.0
|
||||
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!
|
||||
|
||||
|
@ -56,8 +56,13 @@ You have to remove the default yum package, named `php-pecl-memcache` and instal
|
|||
|
||||
== Changelog ==
|
||||
|
||||
= 0.6.1 =
|
||||
*2013.03.08*
|
||||
|
||||
* refactored & corrected backend status check for memcached driver
|
||||
|
||||
= 0.6 =
|
||||
*development branch*
|
||||
*2013.03.08*
|
||||
|
||||
* true WordPress Network support:
|
||||
* 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'))
|
||||
return false;
|
||||
if ( $wp_ffpc_backend == NULL )
|
||||
{
|
||||
$wp_ffpc_backend = new Memcache();
|
||||
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_config['persistent'] = ( $wp_ffpc_config['persistent'] == '1' ) ? true : false;
|
||||
if ( $wp_ffpc_backend_status[$server_id] )
|
||||
$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'] );
|
||||
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_config['persistent'] = ( $wp_ffpc_config['persistent'] == '1' ) ? true : false;
|
||||
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_log ( "server " . $server_id . " added, persistent mode: " . $wp_ffpc_config['persistent'] );
|
||||
}
|
||||
}
|
||||
return $wp_ffpc_backend_status;
|
||||
break;
|
||||
|
||||
/* 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 */
|
||||
if (!class_exists('Memcached'))
|
||||
return false;
|
||||
/* check is there's no backend connection yet */
|
||||
if ( $wp_ffpc_backend == NULL )
|
||||
{
|
||||
/* persistent backend needs an identifier */
|
||||
if ( $wp_ffpc_config['persistent'] == '1' )
|
||||
$wp_ffpc_backend = new Memcached( WP_FFPC_PARAM );
|
||||
else
|
||||
$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_BINARY_PROTOCOL , true );
|
||||
$wp_ffpc_serverlist = $wp_ffpc_backend->getServerList();
|
||||
|
||||
if ( empty ( $wp_ffpc_serverlist ) )
|
||||
$wp_ffpc_backend->addServers( $wp_ffpc_config['servers'] );
|
||||
wp_ffpc_log ( "servers added, persistent mode: " . $wp_ffpc_config['persistent'] );
|
||||
}
|
||||
$wp_ffpc_backend_report = $wp_ffpc_backend->getStats();
|
||||
|
||||
foreach ( $wp_ffpc_config['servers'] as $server_id => $server ) {
|
||||
$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 ) {
|
||||
$wp_ffpc_backend_status[$server_id] = 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();
|
||||
|
||||
/* create check array if backend servers are already connected */
|
||||
if ( !empty ( $wp_ffpc_serverlist ) )
|
||||
foreach ( $wp_ffpc_serverlist as $server )
|
||||
$wp_ffpc_serverlist_[ $server['host'] . ":" . $server['port'] ] = true;
|
||||
|
||||
/* 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 ) {
|
||||
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;
|
||||
/* if server uptime is not empty, it's most probably up & running */
|
||||
if ( !empty($server['uptime']) )
|
||||
$wp_ffpc_backend_status[$server_id] = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
/* cache type is invalid */
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
return ( empty ( $wp_ffpc_backend_status ) ? false : $wp_ffpc_backend_status );
|
||||
|
|
21
wp-ffpc.php
21
wp-ffpc.php
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
Plugin Name: WP-FFPC
|
||||
Version: 0.6
|
||||
Version: 0.6.1
|
||||
Plugin URI: http://petermolnar.eu/wordpress/wp-ffpc
|
||||
Description: Fast Full Page Cache, backend can be memcached or APC
|
||||
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_FILE' , plugin_basename(__FILE__) );
|
||||
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' ) )
|
||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||
|
@ -163,6 +163,13 @@ if (!class_exists('WPFFPC')) {
|
|||
/* not network, will be in simple admin menu */
|
||||
else
|
||||
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 */
|
||||
foreach ( $this->options['servers'] as $server_string => $server ) {
|
||||
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>' ;
|
||||
echo $server_status ."<br />\n";
|
||||
if ( is_array($init) && $init[$server_string] === false )
|
||||
_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>
|
||||
|
@ -686,7 +697,7 @@ if (!class_exists('WPFFPC')) {
|
|||
'prefix_data' =>'data-',
|
||||
'charset' => 'utf-8',
|
||||
'pingback_status'=> false,
|
||||
'debug' => true,
|
||||
'debug' => false,
|
||||
'syslog' => false,
|
||||
'cache_type' => 'memcached',
|
||||
'cache_loggedin' => false,
|
||||
|
|
Loading…
Reference in a new issue