bugfix, version v0.2.2
git-svn-id: http://plugins.svn.wordpress.org/wp-ffpc/trunk@508069 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
parent
47f1cf2f8f
commit
180ad0f2bf
3 changed files with 41 additions and 34 deletions
|
@ -3,7 +3,7 @@ Contributors: cadeyrn
|
|||
Tags: cache, APC, memcached, full page cache
|
||||
Requires at least: 3.0
|
||||
Tested up to: 3.3.1
|
||||
Stable tag: 0.2.1
|
||||
Stable tag: 0.2.2
|
||||
|
||||
Fast Full Page Cache, backend can be memcached or APC
|
||||
|
||||
|
@ -46,18 +46,21 @@ Some parts were based on [Hyper Cache](http://wordpress.org/extend/plugins/hyper
|
|||
|
||||
== Changelog ==
|
||||
|
||||
= 0.2.2 =
|
||||
2012.02.21
|
||||
|
||||
* memcache types bugfix, reported in forum, thanks!
|
||||
|
||||
= 0.2.1 =
|
||||
2012.02.21
|
||||
|
||||
* bugfix, duplicated inclusion could emerge, fix added, thanks for Géza Kuti for reporting!
|
||||
|
||||
|
||||
= 0.2 =
|
||||
2012.02.19
|
||||
|
||||
* added APC compression option ( requires PHP ZLIB ). Useful is output pages are large. Compression is on lowest level, therefore size/CPU load is more or less optimal.
|
||||
|
||||
|
||||
= 0.1 =
|
||||
2012.02.16
|
||||
|
||||
|
|
|
@ -20,18 +20,15 @@ if ( function_exists('wp_ffpc_init') || function_exists('wp_ffpc_clear') || func
|
|||
* if false, backend will be globally initiated
|
||||
* when set, backend will not become global, just tested if alive
|
||||
*/
|
||||
function wp_ffpc_init( $type = false ) {
|
||||
global $wp_ffpc_config;
|
||||
function wp_ffpc_init( $wp_ffpc_config ) {
|
||||
global $wp_ffpc_backend;
|
||||
$wp_ffpc_backend_status = false;
|
||||
|
||||
$reg_backend = $type;
|
||||
// $type is to test an exact backend */
|
||||
if ( !$type )
|
||||
$type = $wp_ffpc_config['cache_type'];
|
||||
|
||||
if ( empty ( $wp_ffpc_config ))
|
||||
global $wp_ffpc_config;
|
||||
|
||||
/* verify selected storage is available */
|
||||
switch ($type)
|
||||
switch ( $wp_ffpc_config['cache_type'] )
|
||||
{
|
||||
/* in case of apc */
|
||||
case 'apc':
|
||||
|
@ -49,10 +46,11 @@ function wp_ffpc_init( $type = false ) {
|
|||
/* Memcache class does not exist, Memcache extension is not available */
|
||||
if (!class_exists('Memcache'))
|
||||
return false;
|
||||
if ($reg_backend)
|
||||
global $wp_ffpc_backend;
|
||||
$wp_ffpc_backend = new Memcache();
|
||||
$wp_ffpc_backend->addServer( $wp_ffpc_config['host'] , $wp_ffpc_config['port'] );
|
||||
if ( $wp_ffpc_backend == NULL )
|
||||
{
|
||||
$wp_ffpc_backend = new Memcache();
|
||||
$wp_ffpc_backend->addServer( $wp_ffpc_config['host'] , $wp_ffpc_config['port'] );
|
||||
}
|
||||
$wp_ffpc_backend_status = $wp_ffpc_backend->getServerStatus( $wp_ffpc_config['host'] , $wp_ffpc_config['port'] );
|
||||
break;
|
||||
|
||||
|
@ -61,10 +59,11 @@ function wp_ffpc_init( $type = false ) {
|
|||
/* Memcached class does not exist, Memcached extension is not available */
|
||||
if (!class_exists('Memcached'))
|
||||
return false;
|
||||
if ($reg_backend)
|
||||
global $wp_ffpc_backend;
|
||||
$wp_ffpc_backend = new Memcached();
|
||||
$wp_ffpc_backend->addServer( $wp_ffpc_config['host'] , $wp_ffpc_config['port'] );
|
||||
if ( $wp_ffpc_backend == NULL )
|
||||
{
|
||||
$wp_ffpc_backend = new Memcached();
|
||||
$wp_ffpc_backend->addServer( $wp_ffpc_config['host'] , $wp_ffpc_config['port'] );
|
||||
}
|
||||
$wp_ffpc_backend_status = array_key_exists( $wp_ffpc_config['host'] . ':' . $wp_ffpc_config['port'] , $wp_ffpc_backend->getStats() );
|
||||
break;
|
||||
|
||||
|
@ -143,6 +142,7 @@ function wp_ffpc_clear ( $post_id = false ) {
|
|||
*/
|
||||
function wp_ffpc_set ( &$key, &$data, $compress = false ) {
|
||||
global $wp_ffpc_config;
|
||||
global $wp_ffpc_backend;
|
||||
|
||||
switch ($wp_ffpc_config['cache_type'])
|
||||
{
|
||||
|
@ -150,16 +150,20 @@ function wp_ffpc_set ( &$key, &$data, $compress = false ) {
|
|||
/* use apc_store to overwrite data is existed */
|
||||
if ( $compress )
|
||||
$data = gzdeflate ( $data , 1 );
|
||||
apc_store( $key , $data , $wp_ffpc_config['expire']);
|
||||
return apc_store( $key , $data , $wp_ffpc_config['expire']);
|
||||
break;
|
||||
case 'memcache':
|
||||
global $wp_ffpc_backend;
|
||||
/* false to disable compression, vital for nginx */
|
||||
$wp_ffpc_backend->set ( $key, $data , false, $wp_ffpc_config['expire'] );
|
||||
if ( $wp_ffpc_backend != NULL )
|
||||
/* false to disable compression, vital for nginx */
|
||||
$wp_ffpc_backend->set ( $key, $data , false, $wp_ffpc_config['expire'] );
|
||||
else
|
||||
return false;
|
||||
break;
|
||||
case 'memcached':
|
||||
global $wp_ffpc_backend;
|
||||
$wp_ffpc_backend->set ( $key, $data , $wp_ffpc_config['expire'] );
|
||||
if ( $wp_ffpc_backend != NULL )
|
||||
$wp_ffpc_backend->set ( $key, $data , $wp_ffpc_config['expire'] );
|
||||
else
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -172,6 +176,7 @@ function wp_ffpc_set ( &$key, &$data, $compress = false ) {
|
|||
*/
|
||||
function wp_ffpc_get( &$key , $uncompress = false ) {
|
||||
global $wp_ffpc_config;
|
||||
global $wp_ffpc_backend;
|
||||
|
||||
switch ($wp_ffpc_config['cache_type'])
|
||||
{
|
||||
|
@ -182,8 +187,10 @@ function wp_ffpc_get( &$key , $uncompress = false ) {
|
|||
return $value;
|
||||
case 'memcache':
|
||||
case 'memcached':
|
||||
global $wp_ffpc_backend;
|
||||
return $wp_ffpc_backend->get($key);
|
||||
if ( $wp_ffpc_backend != NULL )
|
||||
return $wp_ffpc_backend->get($key);
|
||||
else
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
11
wp-ffpc.php
11
wp-ffpc.php
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
Plugin Name: WP-FFPC
|
||||
Version: 0.2.1
|
||||
Version: 0.2.2
|
||||
Plugin URI: http://petermolnar.eu/wordpress/wp-ffpc
|
||||
Description: Fast Full Page Cache, backend can be memcached or APC
|
||||
Author: Peter Molnar
|
||||
|
@ -75,7 +75,7 @@ if (!class_exists('WPFFPC')) {
|
|||
$this->get_options();
|
||||
|
||||
/* check is backend is available */
|
||||
$alive = wp_ffpc_init( $this->options['cache_type'] );
|
||||
$alive = wp_ffpc_init( $this->options );
|
||||
|
||||
/* don't register hooks if backend is dead */
|
||||
if ($alive)
|
||||
|
@ -328,12 +328,9 @@ if (!class_exists('WPFFPC')) {
|
|||
<div>
|
||||
<strong><?php _e( 'Memcached server status: ', WP_FFPC_PARAM ) ; ?>
|
||||
<?php
|
||||
if (class_exists('Memcache'))
|
||||
$server_status = wp_ffpc_init('memcache');
|
||||
elseif (class_exists('Memcached'))
|
||||
$server_status = wp_ffpc_init('memcached');
|
||||
$server_status = wp_ffpc_init( $this->options);
|
||||
|
||||
$server_status = ( $server_status ) ? '<span class="error-msg">down</span>' : '<span class="ok-msg">up & running</span>' ;
|
||||
$server_status = ( empty($server_status) || $server_status == 0 ) ? '<span class="error-msg">down</span>' : '<span class="ok-msg">up & running</span>' ;
|
||||
echo $server_status;
|
||||
?>
|
||||
</strong>
|
||||
|
|
Loading…
Reference in a new issue