cleanup for development hibernation
This commit is contained in:
parent
87b2f986a1
commit
705afd1535
4 changed files with 109 additions and 273 deletions
|
@ -1,156 +0,0 @@
|
|||
<?php
|
||||
|
||||
if (!class_exists('WP_FFPC_Backend_redis')):
|
||||
|
||||
class WP_FFPC_Backend_redis extends WP_FFPC_Backend {
|
||||
|
||||
protected function _init () {
|
||||
/* Memcached class does not exist, Memcached extension is not available */
|
||||
if (!class_exists('Redis')) {
|
||||
$this->log ( __translate__('Redis extension missing, wp-ffpc will not be able to function correctly!', $this->plugin_constant ), LOG_WARNING );
|
||||
return false;
|
||||
}
|
||||
|
||||
/* check for existing server list, otherwise we cannot add backends */
|
||||
if ( empty ( $this->options['servers'] ) && ! $this->alive ) {
|
||||
$this->log ( __translate__("Redis servers list is empty, init failed", $this->plugin_constant ), LOG_WARNING );
|
||||
return false;
|
||||
}
|
||||
|
||||
/* check is there's no backend connection yet */
|
||||
if ( $this->connection === NULL ) {
|
||||
$this->connection = new Redis();
|
||||
}
|
||||
|
||||
/* check if initialization was success or not */
|
||||
if ( $this->connection === NULL ) {
|
||||
$this->log ( __translate__( 'error initializing Redis PHP extension, exiting', $this->plugin_constant ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
/* check if we already have list of servers, only add server(s) if it's not already connected *
|
||||
$servers_alive = array();
|
||||
if ( !empty ( $this->status ) ) {
|
||||
$servers_alive = $this->connection->getServerList();
|
||||
/* create check array if backend servers are already connected *
|
||||
if ( !empty ( $servers ) ) {
|
||||
foreach ( $servers_alive as $skey => $server ) {
|
||||
$skey = $server['host'] . ":" . $server['port'];
|
||||
$servers_alive[ $skey ] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* adding servers */
|
||||
foreach ( $this->options['servers'] as $server_id => $server ) {
|
||||
/* only add servers that does not exists already in connection pool */
|
||||
if ( !@array_key_exists($server_id , $servers_alive ) ) {
|
||||
|
||||
if ( $server['port'] != 0)
|
||||
$this->connection->connect($server['host'], $server['port'] );
|
||||
else
|
||||
$this->connection->connect($server['host'] );
|
||||
|
||||
if ( isset($this->options['authpass']) && !empty($this->options['authpass']) )
|
||||
$this->connection->auth ( $this->options['authpass'] );
|
||||
|
||||
$this->log ( sprintf( __translate__( '%s added', $this->plugin_constant ), $server_id ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* backend is now alive */
|
||||
$this->alive = true;
|
||||
$this->_status();
|
||||
}
|
||||
|
||||
/**
|
||||
* sets current backend alive status for Memcached servers
|
||||
*
|
||||
*/
|
||||
protected function _status () {
|
||||
/* server status will be calculated by getting server stats */
|
||||
|
||||
$this->log ( __translate__("checking server status", $this->plugin_constant ));
|
||||
|
||||
try {
|
||||
$info = $this->connection->ping();
|
||||
} catch ( Exception $e ) {
|
||||
$this->log ( __translate__("Exception occured: " . json_encode($e), $this->plugin_constant ));
|
||||
}
|
||||
|
||||
$status = empty( $info ) ? 0 : 1;
|
||||
|
||||
foreach ( $this->options['servers'] as $server_id => $server ) {
|
||||
/* reset server status to offline */
|
||||
$this->status[$server_id] = $status;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* get function for Memcached backend
|
||||
*
|
||||
* @param string $key Key to get values for
|
||||
*
|
||||
*/
|
||||
protected function _get ( &$key ) {
|
||||
return $this->connection->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set function for Memcached backend
|
||||
*
|
||||
* @param string $key Key to set with
|
||||
* @param mixed $data Data to set
|
||||
*
|
||||
*/
|
||||
protected function _set ( &$key, &$data, &$expire ) {
|
||||
$result = $this->connection->set ( $key, $data, $expire );
|
||||
|
||||
/* if storing failed, log the error code */
|
||||
//if ( $result === false ) {
|
||||
$this->log ( sprintf( __translate__( 'set entry returned: %s', $this->plugin_constant ), $result ) );
|
||||
//}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Flush memcached entries
|
||||
*/
|
||||
protected function _flush ( ) {
|
||||
try {
|
||||
$r = $this->connection->flushDB();
|
||||
} catch ( Exception $e ) {
|
||||
$this->log ( sprintf( __translate__( 'unable to flush, error: %s', $this->plugin_constant ), json_encode($r) ) );
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes entry from Memcached or flushes Memcached storage
|
||||
*
|
||||
* @param mixed $keys String / array of string of keys to delete entries with
|
||||
*/
|
||||
protected function _clear ( &$keys ) {
|
||||
|
||||
/* make an array if only one string is present, easier processing */
|
||||
if ( !is_array ( $keys ) )
|
||||
$keys = array ( $keys => true );
|
||||
|
||||
try {
|
||||
$kresult = $this->connection->delete( $keys );
|
||||
} catch ( Exception $e ) {
|
||||
$this->log ( sprintf( __translate__( 'unable to delete entry(s): %s', $this->plugin_constant ), json_encode($key) ) );
|
||||
$this->log ( sprintf( __translate__( 'Redis error: %s', $this->plugin_constant ), json_encode($e) ) );
|
||||
}
|
||||
finally {
|
||||
$this->log ( sprintf( __translate__( 'entry(s) deleted: %s', $this->plugin_constant ), json_encode($keys) ) );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
114
readme.txt
114
readme.txt
|
@ -1,91 +1,72 @@
|
|||
=== WP-FFPC ===
|
||||
Contributors: cadeyrn, ameir, haroldkyle, plescheff, dkcwd, IgorCode
|
||||
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
|
||||
Contributors: cadeyrn
|
||||
Tags: cache, nginx, memcached, apc
|
||||
Requires at least: 3.0
|
||||
Tested up to: 4.5
|
||||
Stable tag: 1.11.2
|
||||
Tested up to: 4.7.2
|
||||
Stable tag: 1.11.1
|
||||
License: GPLv3
|
||||
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
The fastest way to cache: use the memory!
|
||||
A fast, memory based full page cache plugin supporting APC or memcached.
|
||||
|
||||
== 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.
|
||||
**WARNING** The development of WP-FFPC had been put on hold.
|
||||
If you need new features, please send code and pull requests to [WP FFPC @ Github](https://github.com/petermolnar/wp-ffpc).
|
||||
|
||||
It can be configured to join forces with [NGiNX](http://NGiNX.org "NGiNX")'s built-in [memcached plugin](http://nginx.org/en/docs/http/ngx_http_memcached_module.html "memcached plugin").
|
||||
*A short why: I developed this plugin in 2010 to support my own site. Right now, as it is, it's working on a few sites I still maintain for friends and since I don't need any additional features, I'm not planning to extend it with things I have no real use of. During the past years I've received some heartwarning donations - unfortunately the amount never came close to consider the project financially beneficial. I removed the donation links and put it on hold for now.*
|
||||
|
||||
= **IMPORTANT NOTES, PLEASE READ THIS LIST** =
|
||||
|
||||
* Requirements:
|
||||
* WordPress >= 3.0
|
||||
* **at least one** of the following for storage backend:
|
||||
WP-FFPC is a cache plugin for [WordPress](http://wordpress.org/ "WordPress").
|
||||
It works with any webserver, including, but not limited to, apache2, lighttpd, nginx.
|
||||
|
||||
It can be configured together with [NGiNX](http://NGiNX.org "NGiNX") but use [memcached plugin](http://nginx.org/en/docs/http/ngx_http_memcached_module.html "memcached plugin") directly from the webserver, bypassing PHP.
|
||||
|
||||
= Requirements =
|
||||
|
||||
**This plugin does not kick in right after activation**. You have to adjust the setting in Settings -> WP-FFPC and save the settings.*
|
||||
|
||||
* WordPress >= 3.0
|
||||
* **at least one** of the following for storage backend:
|
||||
* 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")
|
||||
* PHP 5.3+ is really highly recommended, see "Known issues"
|
||||
* This plugin does **not** kick in right after activation. You have to adjust the setting in Settings -> WP-FFPC and save the settings.*
|
||||
* PHP 5.3+ is really highly recommended, see "Known issues"
|
||||
|
||||
|
||||
= Known issues =
|
||||
|
||||
* errors will not be displayed on the admin section if PHP < 5.3, only in the logs. This is due to the limitations of displaying the errors ( admin_notices is a hook, not a filter ) and due to the lack of proper anonymus functions in older PHP. PHP 5.3 is 5 years old, so it's time to upgrade.
|
||||
* APC with PHP 5.4 is buggy; the plugin with that setup can even make your site slower. Please use APCu or memcached if you're using PHP >= 5.4
|
||||
* errors will not be displayed on the admin section if PHP < 5.3, only in the logs. This is due to the limitations of displaying the errors ( admin_notices is a hook, not a filter ) and due to the lack of proper anonymus functions in older PHP.
|
||||
* **If you're using PHP 5.4+ avoid the APC backend: the plugin with that setup can even make your site slower.** Please use APCu or memcached in this case.
|
||||
|
||||
= Features: =
|
||||
|
||||
* Wordpress Network support
|
||||
* fully supported domain/subdomain based WordPress Networks on per site setup as well
|
||||
* will work in Network Enabled mode only for subdirectory based Multisites ( per site settings will not work in this case )
|
||||
* supports various backends
|
||||
* various backends
|
||||
* 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 options ( home, feeds, archieves, pages, singles; regex based url exclusion )
|
||||
* minor Woocommerce support
|
||||
* (optional) cache for logged-in users
|
||||
* 404 caching
|
||||
* canonical redirects caching
|
||||
* Last Modified HTTP header support ( for 304 responses )
|
||||
* Last Modified HTTP header support (for 304 responses)
|
||||
* shortlink HTTP header preservation
|
||||
* pingback HTTP header preservation
|
||||
* 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
|
||||
* (**warning**: untested since WordPress 3.8) Wordpress Network support
|
||||
* fully supported domain/subdomain based WordPress Networks on per site setup as well
|
||||
* will work in Network Enabled mode only for subdirectory based Multisites ( per site settings will not work in this case )
|
||||
|
||||
|
||||
Many thanks for donations, contributors, supporters, testers & bug reporters:
|
||||
|
||||
* [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)
|
||||
* Miguel Clara
|
||||
* [Anton Pelešev](https://github.com/plescheff)
|
||||
* Firas Dib
|
||||
* [CotswoldPhoto](http://wordpress.org/support/profile/cotswoldphoto)
|
||||
* [tamagokun](https://github.com/tamagokun)
|
||||
* Many Ayromlou
|
||||
* mailgarant.nl
|
||||
* Christian Rößner
|
||||
* [Ameir Abdeldayem](https://github.com/ameir)
|
||||
* [Alvaro Gonzalez](https://github.com/andor-pierdelacabeza)
|
||||
* Meint Post
|
||||
* Knut Sparhell
|
||||
* Christian Kernbeis
|
||||
* Gausden Barry
|
||||
* Maksim Bukreyeu
|
||||
* Lissome Hong Kong Limited
|
||||
* [Gabriele Lauricella](https://github.com/gablau)
|
||||
* 7th Veil, LLC
|
||||
* Julia Harsch
|
||||
* Grant Berntsen
|
||||
Harold Kyle, Eric Gilette, doconeill, Mark Costlow, Jason Miller, Dave Clark, Miguel Clara, Anton Pelešev, Firas Dib, CotswoldPhoto, tamagokun, Many Ayromlou, mailgarant.nl, Christian Rößner, Ameir Abdeldayem, Alvaro Gonzalez, Meint Post, Knut Sparhell, Christian Kernbeis, Gausden Barry, Maksim Bukreyeu, Lissome Hong Kong Limited, Gabriele Lauricella, 7th Veil, LLC, Julia Harsch, Grant Berntsen, Jorgen Ilstad, Cinema Minima for Movie Makers Worldwide
|
||||
|
||||
== Installation ==
|
||||
|
||||
|
@ -102,22 +83,27 @@ A short configuration example is generated on the plugin settings page, under `N
|
|||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= How to use the plugin on Amazon Linux? =
|
||||
You have to remove the default yum package, named `php-pecl-memcache` and install `Memcached` through PECL.
|
||||
= The plugin is not working! =
|
||||
|
||||
= How to use the plugin in a WordPress Network =
|
||||
From version 1.0, the plugin supports subdomain based WordPress Network with possible different per site cache settings. If the plugin is network active, obviously the network wide settings will be used for all of the sites. If it's activated only on some of the sites, the other will not be affected and even the cache storage backend can be different from site to site.
|
||||
Did you save the settings as mentioned in this document?
|
||||
Do you have at lest one supported backend?
|
||||
|
||||
= How logging works in the plugin? =
|
||||
Log levels by default ( if logging enabled ) includes warning and error level standard PHP messages.
|
||||
Additional info level log is available when [WP_DEBUG](http://codex.wordpress.org/WP_DEBUG "WP_DEBUG") is enabled.
|
||||
= It's making my site slower than it was! =
|
||||
|
||||
= How can I contribute? =
|
||||
In order to make contributions a lot easier, I've moved the plugin development to [GitHub](https://github.com/petermolnar/wp-ffpc "GitHub"), feel free to fork and put shiny, new things in it and get in touch with me [hello@petermolnar.eu](mailto:hello@petermolnar.eu "hello@petermolnar.eu") when you have it ready.
|
||||
So far this only happened if PHP 5.4 or higher was used with APC.
|
||||
Please avoid this setup; PHP 5.4 shipped opcache and APC is full of bugs since then. Use APCu with PHP 5.4+.
|
||||
|
||||
= Does it support mobile theme switching? =
|
||||
|
||||
No, it doesn't, and with the way it's currently working, it never will.
|
||||
WP-FFPC is using the URL as key for caching, so it can't differentiate if there is no change in the URL.
|
||||
*(I personally also disagree with separation of mobile and non-mobile theme; you need to support a plethora of screen sizes and resolutions, so just use responsive designs instead of splitted logics.)*
|
||||
|
||||
= Can you please add '(insert shiny new feature here)'? =
|
||||
|
||||
Sure. Send me a code and a pull request on [WP FFPC @ Github](https://github.com/petermolnar/wp-ffpc).
|
||||
Unfortunately I don't have the resources to code it myself, but there are plenty of WordPress developers who would probably do it for a minor fee.
|
||||
|
||||
= Where can I turn for support? =
|
||||
I provide support for the plugin as best as I can, but it comes without guarantee.
|
||||
Please post feature requests to [WP-FFPC feature request topic](http://wordpress.org/support/topic/feature-requests-14 "WP-FFPC feature request topic") and any questions on the forum.
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
|
@ -135,6 +121,14 @@ Version numbering logic:
|
|||
* every .B version indicates new features.
|
||||
* every ..C indicates bugfixes for A.B version.
|
||||
|
||||
= 1.11.2 =
|
||||
*2017-02-08*
|
||||
|
||||
* nonexistent redis support removed (it never got to a usable stable state, mostly due to the chaos with the redis php modules)
|
||||
* readme cleaned up for development hibernation
|
||||
* donation link removed
|
||||
* WP version compatibility bumped
|
||||
|
||||
= 1.11.1 =
|
||||
*2016-04-21*
|
||||
|
||||
|
|
|
@ -135,7 +135,6 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
|
|||
'apcu' => __( 'APCu' , 'wp-ffpc'),
|
||||
'memcache' => __( 'PHP Memcache' , 'wp-ffpc'),
|
||||
'memcached' => __( 'PHP Memcached' , 'wp-ffpc'),
|
||||
'redis' => __( 'Redis (experimental, it will break!)' , 'wp-ffpc'),
|
||||
);
|
||||
/* check for required functions / classes for the cache types */
|
||||
|
||||
|
@ -144,7 +143,6 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
|
|||
'apcu' => function_exists( 'apcu_cache_info' ) ? true : false,
|
||||
'memcache' => class_exists ( 'Memcache') ? true : false,
|
||||
'memcached' => class_exists ( 'Memcached') ? true : false,
|
||||
'redis' => class_exists( 'Redis' ) ? true : false,
|
||||
);
|
||||
|
||||
/* invalidation method possible values array */
|
||||
|
@ -790,7 +788,7 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
|
|||
<?php _e('List of backends, with the following syntax: <br />- in case of TCP based connections, list the servers as host1:port1,host2:port2,... . Do not add trailing , and always separate host and port with : .<br />- for a unix socket enter: unix://[socket_path]', 'wp-ffpc'); ?></span>
|
||||
</dd>
|
||||
|
||||
<h3><?php _e('Authentication ( only for SASL enabled Memcached or Redis)')?></h3>
|
||||
<h3><?php _e('Authentication ( only for SASL enabled Memcached)')?></h3>
|
||||
<?php
|
||||
if ( ! ini_get('memcached.use_sasl') && ( !empty( $this->options['authuser'] ) || !empty( $this->options['authpass'] ) ) ) { ?>
|
||||
<div class="error"><p><strong><?php _e( 'WARNING: you\'ve entered username and/or password for memcached authentication ( or your browser\'s autocomplete did ) which will not work unless you enable memcached sasl in the PHP settings: add `memcached.use_sasl=1` to php.ini' , 'wp-ffpc') ?></strong></p></div>
|
||||
|
|
14
wp-ffpc.php
14
wp-ffpc.php
|
@ -5,13 +5,13 @@ Plugin URI: https://github.com/petermolnar/wp-ffpc
|
|||
Description: WordPress in-memory full page cache plugin
|
||||
Version: 1.11.1
|
||||
Author: Peter Molnar <hello@petermolnar.eu>
|
||||
Author URI: http://petermolnar.eu/
|
||||
Author URI: http://petermolnar.net/
|
||||
License: GPLv3
|
||||
Text Domain: wp-ffpc
|
||||
Domain Path: /languages/
|
||||
*/
|
||||
|
||||
/* Copyright 2010-2014 Peter Molnar ( hello@petermolnar.eu )
|
||||
/*Copyright 2010-2017 Peter Molnar ( hello@petermolnar.eu )
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 3, as
|
||||
|
@ -19,20 +19,20 @@ Domain Path: /languages/
|
|||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA02110-1301USA
|
||||
*/
|
||||
|
||||
defined('ABSPATH') or die("Walk away.");
|
||||
|
||||
include_once ( 'wp-ffpc-class.php' );
|
||||
|
||||
$wp_ffpc_defaults = array (
|
||||
'hosts'=>'127.0.0.1:11211',
|
||||
$wp_ffpc_defaults= array (
|
||||
'hosts' => '127.0.0.1:11211',
|
||||
'memcached_binary' => false,
|
||||
'authpass' => '',
|
||||
'authuser' => '',
|
||||
|
@ -69,4 +69,4 @@ $wp_ffpc_defaults = array (
|
|||
'hashkey' => false,
|
||||
);
|
||||
|
||||
$wp_ffpc = new WP_FFPC ( 'wp-ffpc', '1.11.2', 'WP-FFPC', $wp_ffpc_defaults, 'PeterMolnar_WordPressPlugins_wp-ffpc_HU' , 'WP-FFPC' , 'FA3NT7XDVHPWU' );
|
||||
$wp_ffpc= new WP_FFPC ( 'wp-ffpc', '1.11.1', 'WP-FFPC', $wp_ffpc_defaults );
|
Loading…
Reference in a new issue