version 1.5.0 with APCu

This commit is contained in:
Peter Molnar 2014-05-30 11:22:21 +01:00
parent 58fcf95b9a
commit 6e4d474796
4 changed files with 120 additions and 19 deletions

View file

@ -3,12 +3,12 @@ Contributors: cadeyrn
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XU3DG7LLA76WC
Tags: cache, page cache, full page cache, nginx, memcached, apc, speed
Requires at least: 3.0
Tested up to: 3.9
Stable tag: 1.4.0
Tested up to: 3.9.1
Stable tag: 1.5.0
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
The fastest way to cache: full page in memory cache for WordPress!
The fastest way to cache: use the memory!
== Description ==
WP-FFPC ( WordPress Fast Full Page Cache ) is a cache plugin for [WordPress](http://wordpress.org/ "WordPress"). It works with any webserver, including apache2, lighttpd, nginx.
@ -16,12 +16,14 @@ It can be configured to join forces with [NGiNX](http://NGiNX.org "NGiNX")'s bui
= Features: =
* Wordpress Network support
* fully supported domain/subdomain Networks
* fully supported domain/subdomain based WordPress Networks on per site setup as well
* will work in Network Enabled mode only for subdirectory based Multisites ( no per site setting possibility )
* supports variable backends
* memcached with PHP Memcached
* memcached with PHP Memcache
* APC
* memcached with [PHP Memcached](http://php.net/manual/en/book.memcached.php "Memcached")
* memcached with [PHP Memcache](http://php.net/manual/en/book.memcache.php "Memcache")
* [APC](http://php.net/manual/en/book.apc.php "APC")
* [APCu](http://pecl.php.net/package/APCu "APC User Cache")
* [Xcache](http://xcache.lighttpd.net/ "Xcache") - not stable yet, volunteer testers required!
* cache exclude possibilities ( home, feeds, archieves, pages, singles )
* (optional) cache for logged-in users
* 404 caching
@ -33,7 +35,7 @@ It can be configured to join forces with [NGiNX](http://NGiNX.org "NGiNX")'s bui
* multiple memcached upstream support
* precache ( manually or by timed by wp-cron )
Many thanks for contributors, supporters, testers & bug reporters:
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")
@ -69,10 +71,11 @@ From version 1.0, the plugin supports subdomain based WordPress Network with pos
and **at least one** of the following for storage backend:
* PHP APC
* PHP Memcached > 0.1.0
* PHP Memcache > 2.1.0
* Xcache
* memcached with [PHP Memcached](http://php.net/manual/en/book.memcached.php "Memcached") > 0.1.0
* memcached with [PHP Memcache](http://php.net/manual/en/book.memcache.php "Memcache") > 2.1.0
* [APC](http://php.net/manual/en/book.apc.php "APC")
* [APCu](http://pecl.php.net/package/APCu "APC User Cache")
* [Xcache](http://xcache.lighttpd.net/ "Xcache")
= How logging works in the plugin? =
Log levels by default ( if logging enabled ) includes warning and error level standard PHP messages.
@ -95,12 +98,22 @@ Please post feature requests to [WP-FFPC feature request topic](http://wordpress
== Changelog ==
= 1.5.0 =
*2014-05-30*
What's new:
* APCu backend added ( APCu is a stripped version of APC with only user object cache functionality what can be used with PHP 5.4 & 5.5 besides [Opcache](http://php.net/manual/en/book.opcache.php "PHP Opcache") )
= 1.4.0 =
*2014-05-12*
What's changed:
What's new:
* Xcache backend added ( theoretical, partially tested, volunteer testers required )
What's fixed:
* Xcache backend added ( alpha version, still under heavy testing )
* invalidation for comment actions added
= 1.3.3 =

View file

@ -166,7 +166,7 @@ if (!class_exists('WP_FFPC_Backend')) {
$this->log ( sprintf( __translate__( 'set %s expiration time: %s', $this->plugin_constant ), $key, $this->options['expire'] ) );
/* proxy to internal function */
$internal = $this->options['cache_type'] . '_set';
$internal = $this->proxy( 'set' );
$result = $this->$internal( $key, $data );
/* check result validity */
@ -448,13 +448,13 @@ if (!class_exists('WP_FFPC_Backend')) {
*/
private function apc_init () {
/* verify apc functions exist, apc extension is loaded */
if ( ! function_exists( 'apc_sma_info' ) ) {
if ( ! function_exists( 'apc_cache_info' ) ) {
$this->log ( __translate__('APC extension missing', $this->plugin_constant ) );
return false;
}
/* verify apc is working */
if ( apc_sma_info() ) {
if ( apc_cache_info("user",true) ) {
$this->log ( __translate__('backend OK', $this->plugin_constant ) );
$this->alive = true;
}
@ -527,6 +527,92 @@ if (!class_exists('WP_FFPC_Backend')) {
}
}
/*********************** END APC FUNCTIONS ***********************/
/*********************** APCu FUNCTIONS ***********************/
/**
* init apcu backend: test APCu availability and set alive status
*/
private function apcu_init () {
/* verify apcu functions exist, apcu extension is loaded */
if ( ! function_exists( 'apcu_cache_info' ) ) {
$this->log ( __translate__('APCu extension missing', $this->plugin_constant ) );
return false;
}
/* verify apcu is working */
if ( apcu_cache_info("user",true) ) {
$this->log ( __translate__('backend OK', $this->plugin_constant ) );
$this->alive = true;
}
}
/**
* health checker for APC
*
* @return boolean Aliveness status
*
*/
private function apcu_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 apcu_get ( &$key ) {
return apcu_fetch( $key );
}
/**
* 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 apcu_set ( &$key, &$data ) {
return apcu_store( $key , $data , $this->options['expire'] );
}
/**
* Flushes APC user entry storage
*
* @return boolean APC flush outcome status
*
*/
private function apcu_flush ( ) {
return apcu_clear_cache();
}
/**
* Removes entry from APC or flushes APC user entry storage
*
* @param mixed $keys Keys to clear, string or array
*/
private function apcu_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 ( ! apcu_delete ( $key ) ) {
$this->log ( sprintf( __translate__( 'Failed to delete APC entry: %s', $this->plugin_constant ), $key ), LOG_ERR );
//throw new Exception ( __translate__('Deleting APC entry failed with key ', $this->plugin_constant ) . $key );
}
else {
$this->log ( sprintf( __translate__( 'APC entry delete: %s', $this->plugin_constant ), $key ) );
}
}
}
/*********************** END APC FUNCTIONS ***********************/
/*********************** XCACHE FUNCTIONS ***********************/

View file

@ -115,13 +115,15 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
/* cache type possible values array */
$this->select_cache_type = array (
'apc' => __( 'APC' , $this->plugin_constant ),
'apcu' => __( 'APCu' , $this->plugin_constant ),
'xcache' => __( 'XCache' , $this->plugin_constant ),
'memcache' => __( 'PHP Memcache' , $this->plugin_constant ),
'memcached' => __( 'PHP Memcached' , $this->plugin_constant ),
);
/* check for required functions / classes for the cache types */
$this->valid_cache_type = array (
'apc' => function_exists( 'apc_sma_info' ) ? true : false,
'apc' => function_exists( 'apc_cache_info' ) ? true : false,
'apcu' => function_exists( 'apcu_cache_info' ) ? true : false,
'xcache' => function_exists( 'xcache_info' ) ? true : false,
'memcache' => class_exists ( 'Memcache') ? true : false,
'memcached' => class_exists ( 'Memcached') ? true : false,

View file

@ -3,7 +3,7 @@
Plugin Name: WP-FFPC
Plugin URI: http://petermolnar.eu/wordpress/wp-ffpc
Description: WordPress cache plugin for memcached & nginx - unbeatable speed
Version: 1.4.0
Version: 1.5.0
Author: Peter Molnar <hello@petermolnar.eu>
Author URI: http://petermolnar.eu/
License: GPLv3