1.7.0 alpha

This commit is contained in:
Peter Molnar 2014-09-19 09:38:54 +01:00
parent 49c4da89f9
commit 0356107ea7
5 changed files with 69 additions and 119 deletions

View file

@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
Tags: cache, page cache, full page cache, nginx, memcached, apc, speed
Requires at least: 3.0
Tested up to: 4.0
Stable tag: 1.6.4
Stable tag: 1.7.0
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
@ -34,17 +34,21 @@ It can be configured to join forces with [NGiNX](http://NGiNX.org "NGiNX")'s bui
* talkative log for [WP_DEBUG](http://codex.wordpress.org/WP_DEBUG "WP_DEBUG")
* multiple memcached upstream support
* precache ( manually or by timed by wp-cron )
* varying expiration time for posts, taxonomies and home
Many thanks for donations, contributors, supporters, testers & bug reporters:
* [Harold Kyle](https://github.com/haroldkyle "Harold Kyle")
* [Eric Gilette](http://www.ericgillette.com/ "Eric Gilette")
* [doconeill](http://wordpress.org/support/profile/doconeill "doconeill")
* [Mark Costlow](mailto:cheeks@swcp.com "Mark Costlow")
* [Jason Miller](mailto:jason@redconfetti.com "Jason Miller")
* [Harold Kyle](https://github.com/haroldkyle)
* [Eric Gilette](http://www.ericgillette.com/)
* [doconeill](http://wordpress.org/support/profile/doconeill)
* Mark Costlow
* Jason Miller
* [Dave Clark](https://github.com/dkcwd "Dave Clark")
* Miguel Clara
* [plescheff](https://github.com/plescheff)
* [CotswoldPhoto](http://wordpress.org/support/profile/cotswoldphoto)
* [tamagokun](https://github.com/tamagokun)
== Installation ==
@ -106,6 +110,13 @@ Version numbering logic:
* every .B version indicates new features.
* every ..C indicates bugfixes for A.B version.
= 1.7.0 =
*2014-09-19*
* **dropped Xcache support**, the reasons behind this is the outstandingly terrible documentation of Xcache
* added varying expiration time options
= 1.6.4 =
*2014-09-12*

View file

@ -52,6 +52,7 @@ elseif ( !empty ( $wp_ffpc_config[ $_SERVER['HTTP_HOST'] ] ) )
else
return false;
/* check for cookies that will make us not cache the content, like logged in WordPress cookie */
if ( isset($wp_ffpc_config['nocache_cookies']) && !empty($wp_ffpc_config['nocache_cookies']) ) {
$nocache_cookies = array_map('trim',explode(",", $wp_ffpc_config['nocache_cookies'] ) );

View file

@ -160,9 +160,21 @@ class WP_FFPC_Backend {
/* log the current action */
$this->log ( sprintf( __translate__( 'set %s expiration time: %s', $this->plugin_constant ), $key, $this->options['expire'] ) );
/* expiration time based is based on type from now on */
/* fallback */
$expire = $this->options['expire'];
if ( is_home() || is_feed() )
$expire = $this->options['expire_home'];
elseif ( is_tax() || is_category() || is_tag() || is_archive() )
$expire = $this->options['expire_taxonomy'];
if ( empty($expire) )
return false;
/* proxy to internal function */
$internal = $this->proxy( 'set' );
$result = $this->$internal( $key, $data );
$result = $this->$internal( $key, $data, $expire );
/* check result validity */
if ( $result === false )
@ -171,6 +183,11 @@ class WP_FFPC_Backend {
return $result;
}
public function clear_ng ( $new_status, $old_status, $post ) {
$this->clear ( $post->ID );
}
/**
* public get function, transparent proxy to internal function based on backend
*
@ -512,8 +529,8 @@ class WP_FFPC_Backend {
*
* @return boolean APC store outcome
*/
private function apc_set ( &$key, &$data ) {
return apc_store( $key , $data , $this->options['expire'] );
private function apc_set ( &$key, &$data, &$expire ) {
return apc_store( $key , $data , $expire );
}
@ -598,8 +615,8 @@ class WP_FFPC_Backend {
*
* @return boolean APC store outcome
*/
private function apcu_set ( &$key, &$data ) {
return apcu_store( $key , $data , $this->options['expire'] );
private function apcu_set ( &$key, &$data, &$expire ) {
return apcu_store( $key , $data , $expire );
}
@ -636,106 +653,6 @@ class WP_FFPC_Backend {
/*********************** END APC FUNCTIONS ***********************/
/*********************** XCACHE FUNCTIONS ***********************/
/**
* init apc backend: test APC availability and set alive status
*/
private function xcache_init () {
/* verify apc functions exist, apc extension is loaded */
if ( ! function_exists( 'xcache_info' ) ) {
$this->log ( __translate__('XCACHE extension missing', $this->plugin_constant ) );
return false;
}
$xcache_admin = ini_get ( 'xcache.admin.user' );
$xcache_pass = ini_get ( 'xcache.admin.pass' );
if ( empty( $xcache_admin ) || empty( $xcache_pass ) ) {
$this->log ( __translate__('XCACHE xcache.admin.user or xcache.admin.pass is not set in php.ini. Please set them, otherwise the use cache part of xcache is not accessible.', $this->plugin_constant ) );
return false;
}
/* verify apc is working */
$info = xcache_info();
if ( !empty( $info )) {
$this->log ( __translate__('backend OK', $this->plugin_constant ) );
$this->alive = true;
}
}
/**
* health checker for Xcache
*
* @return boolean Aliveness status
*
*/
private function xcache_status () {
$this->status = true;
return $this->alive;
}
/**
* get function for APC backend
*
* @param string $key Key to get values for
*
* @return mixed Fetched data based on key
*
*/
private function xcache_get ( &$key ) {
if ( xcache_isset ( $key ) )
return xcache_get( $key );
else
return false;
}
/**
* Set function for APC backend
*
* @param string $key Key to set with
* @param mixed $data Data to set
*
* @return boolean APC store outcome
*/
private function xcache_set ( &$key, &$data ) {
return xcache_set( $key , $data , $this->options['expire'] );
}
/**
* Flushes APC user entry storage
*
* @return boolean APC flush outcome status
*
*/
private function xcache_flush ( ) {
return xcache_clear_cache(XC_TYPE_VAR);
}
/**
* Removes entry from APC or flushes APC user entry storage
*
* @param mixed $keys Keys to clear, string or array
*/
private function xcache_clear ( &$keys ) {
/* make an array if only one string is present, easier processing */
if ( !is_array ( $keys ) )
$keys = array ( $keys => true );
foreach ( $keys as $key => $dummy ) {
if ( ! xcache_unset ( $key ) ) {
$this->log ( sprintf( __translate__( 'Failed to delete XCACHE entry: %s', $this->plugin_constant ), $key ), LOG_WARNING );
//throw new Exception ( __translate__('Deleting APC entry failed with key ', $this->plugin_constant ) . $key );
}
else {
$this->log ( sprintf( __translate__( 'XCACHE entry delete: %s', $this->plugin_constant ), $key ) );
}
}
}
/*********************** END XCACHE FUNCTIONS ***********************/
/*********************** MEMCACHED FUNCTIONS ***********************/
/**
* init memcached backend
@ -845,8 +762,8 @@ class WP_FFPC_Backend {
* @param mixed $data Data to set
*
*/
private function memcached_set ( &$key, &$data ) {
$result = $this->connection->set ( $key, $data , $this->options['expire'] );
private function memcached_set ( &$key, &$data, &$expire ) {
$result = $this->connection->set ( $key, $data , $expire );
/* if storing failed, log the error code */
if ( $result === false ) {
@ -979,8 +896,8 @@ class WP_FFPC_Backend {
* @param mixed $data Data to set
*
*/
private function memcache_set ( &$key, &$data ) {
$result = $this->connection->set ( $key, $data , 0 , $this->options['expire'] );
private function memcache_set ( &$key, &$data, &$expire ) {
$result = $this->connection->set ( $key, $data , 0 , $expire );
return $result;
}

View file

@ -180,6 +180,8 @@ class WP_FFPC extends PluginAbstract {
$post_types = get_post_types( );
/* cache invalidation hooks */
add_action( 'transition_post_status', array( &$this->backend , 'clear_ng' ), 10, 3 );
/*
foreach ( $post_types as $post_type ) {
add_action( 'new_to_publish_' .$post_type , array( &$this->backend , 'clear' ), 0 );
add_action( 'draft_to_publish' .$post_type , array( &$this->backend , 'clear' ), 0 );
@ -187,6 +189,7 @@ class WP_FFPC extends PluginAbstract {
add_action( 'private_to_publish' .$post_type , array( &$this->backend , 'clear' ), 0 );
add_action( 'publish_' . $post_type , array( &$this->backend , 'clear' ), 0 );
}
*/
/* comments invalidation hooks */
if ( $this->options['comments_invalidate'] ) {
@ -462,11 +465,27 @@ class WP_FFPC extends PluginAbstract {
</dd>
<dt>
<label for="expire"><?php _e('Expiration time (seconds)', $this->plugin_constant); ?></label>
<label for="expire"><?php _e('Expiration time for posts', $this->plugin_constant); ?></label>
</dt>
<dd>
<input type="number" name="expire" id="expire" value="<?php echo $this->options['expire']; ?>" />
<span class="description"><?php _e('Sets validity time of entry in seconds', $this->plugin_constant); ?></span>
<span class="description"><?php _e('Sets validity time of post entry in seconds, including custom post types and pages.', $this->plugin_constant); ?></span>
</dd>
<dt>
<label for="expire_taxonomy"><?php _e('Expiration time for taxonomy', $this->plugin_constant); ?></label>
</dt>
<dd>
<input type="number" name="expire_taxonomy" id="expire_taxonomy" value="<?php echo $this->options['expire_taxonomy']; ?>" />
<span class="description"><?php _e('Sets validity time of taxonomy entry in seconds, including custom taxonomy.', $this->plugin_constant); ?></span>
</dd>
<dt>
<label for="expire_home"><?php _e('Expiration time for home', $this->plugin_constant); ?></label>
</dt>
<dd>
<input type="number" name="expire_home" id="expire_home" value="<?php echo $this->options['expire_home']; ?>" />
<span class="description"><?php _e('Sets validity time of home.', $this->plugin_constant); ?></span>
</dd>
<dt>

View file

@ -3,7 +3,7 @@
Plugin Name: WP-FFPC
Plugin URI: https://github.com/petermolnar/wp-ffpc
Description: WordPress in-memory full page cache plugin
Version: 1.6.4
Version: 1.7.0
Author: Peter Molnar <hello@petermolnar.eu>
Author URI: http://petermolnar.eu/
License: GPLv3
@ -32,6 +32,8 @@ $wp_ffpc_defaults = array (
'authpass'=>'',
'authuser'=>'',
'expire'=>300,
'expire_home'=>300,
'expire_taxonomy'=>300,
'invalidation_method'=>0,
'prefix_meta' =>'meta-',
'prefix_data' =>'data-',
@ -55,6 +57,6 @@ $wp_ffpc_defaults = array (
'comments_invalidate' => true,
);
$wp_ffpc = new WP_FFPC ( 'wp-ffpc', '1.6.0', 'WP-FFPC', $wp_ffpc_defaults, 'PeterMolnar_WordPressPlugins_wp-ffpc_HU' , 'WP-FFPC' , 'FA3NT7XDVHPWU' );
$wp_ffpc = new WP_FFPC ( 'wp-ffpc', '1.7.0', 'WP-FFPC', $wp_ffpc_defaults, 'PeterMolnar_WordPressPlugins_wp-ffpc_HU' , 'WP-FFPC' , 'FA3NT7XDVHPWU' );
?>