Changeset 1196126
- Timestamp:
- 07/10/2015 09:01:07 AM (11 years ago)
- Location:
- nginx-helper/trunk
- Files:
-
- 2 added
- 9 edited
-
admin/admin.php (modified) (1 diff)
-
admin/install.php (modified) (1 diff)
-
admin/lib/nginx-general.php (modified) (1 diff)
-
composer.json (added)
-
composer.lock (added)
-
includes/redis-delete.php (modified) (6 diffs)
-
nginx-helper.php (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
-
redis-purger.php (modified) (1 diff)
-
tests/functional/src/purge-method-get-request-page-test.js (modified) (1 diff)
-
tests/functional/src/purge-method-unlink-files-page-test.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
nginx-helper/trunk/admin/admin.php
r1146795 r1196126 119 119 return; 120 120 } 121 $purge_url = esc_url( add_query_arg( array( 'nginx_helper_action' => 'purge', 'nginx_helper_urls' => 'all' )) );121 $purge_url = add_query_arg( array( 'nginx_helper_action' => 'purge', 'nginx_helper_urls' => 'all' ) ); 122 122 $nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' ); 123 123 $admin_bar->add_menu( array( 'id' => 'nginx-helper-purge-all', 'title' => __( 'Purge Cache', 'nginx-helper' ), 'href' => $nonced_url, 'meta' => array( 'title' => __( 'Purge Cache', 'nginx-helper' ), ), ) ); -
nginx-helper/trunk/admin/install.php
r827352 r1196126 94 94 $rt_wp_nginx_helper_get_options[ 'purge_page_on_deleted_comment' ] = 1; 95 95 96 $rt_wp_nginx_helper_get_options[ 'purge_method' ] = 'get_request'; 97 96 98 return $rt_wp_nginx_helper_get_options; 97 99 } -
nginx-helper/trunk/admin/lib/nginx-general.php
r1190839 r1196126 387 387 fclose( $log ); 388 388 } 389 if ( is_writable( $path . 'nginx.log' ) ) { 390 $rt_wp_nginx_purger->log( "+++++++++" ); 391 $rt_wp_nginx_purger->log( "+Log Test" ); 392 $rt_wp_nginx_purger->log( "+++++++++" ); 393 } 389 394 390 if ( !is_writable( $path . 'nginx.log' ) ) { 395 391 ?> -
nginx-helper/trunk/includes/redis-delete.php
r1190839 r1196126 3 3 //TODO:: phpRedis based implementation https://github.com/phpredis/phpredis#eval 4 4 //include predis (php implementation for redis) 5 require_once 'predis.php';6 Predis\Autoloader::register();7 5 8 global $myredis, $rt_wp_nginx_helper ;6 global $myredis, $rt_wp_nginx_helper, $redis_api, $lua; 9 7 10 8 $host = $rt_wp_nginx_helper->options['redis_hostname']; 11 9 $port = $rt_wp_nginx_helper->options['redis_port']; 10 $redis_api = ''; 11 12 if ( class_exists( 'Redis' ) ) { // Use PHP5-Redis if installed. 13 try { 14 $myredis = new Redis(); 15 $myredis->connect( $host, $port ); 16 $redis_api = 'php-redis'; 17 } catch ( Exception $e ) {} 18 } else { 19 if( ! class_exists( 'Predis\Autoloader' ) ) { 20 require_once 'predis.php'; 21 } 22 Predis\Autoloader::register(); 23 24 //redis server parameter 25 $myredis = new Predis\Client( [ 26 'host' => $host, 27 'port' => $port, 28 ] ); 29 //connect 30 try { 31 $myredis->connect(); 32 $redis_api = 'predis'; 33 } catch ( Exception $e ) {} 34 } 12 35 13 36 //Lua Script … … 22 45 LUA; 23 46 24 //redis server parameter25 $myredis = new Predis\Client( [26 'host' => $host,27 'port' => $port,28 ] );29 30 //connect31 try {32 $myredis->connect();33 } catch ( Exception $e ) {34 35 }36 37 38 47 /* 39 48 Delete multiple single keys without wildcard using redis pipeline feature to speed up things … … 42 51 function delete_multi_keys( $key ) 43 52 { 44 global $myredis; 45 $matching_keys = $myredis->keys( $key ); 46 foreach ( $matching_keys as $key => $value ) { 47 $myredis->executeRaw( ['DEL', $value ] ); 48 } 53 global $myredis, $redis_api; 54 if ( !empty( $myredis ) ) { 55 $matching_keys = $myredis->keys( $key ); 56 if( $redis_api == 'predis') { 57 foreach ( $matching_keys as $key => $value ) { 58 $myredis->executeRaw( ['DEL', $value ] ); 59 } 60 } else if( $redis_api == 'php-redis') { 61 return $myredis->del( $matching_keys ); 62 } 63 } else { 64 return false; 65 } 49 66 } 50 67 … … 70 87 function delete_single_key( $key ) 71 88 { 72 global $myredis; 89 global $myredis, $redis_api; 90 73 91 if ( !empty( $myredis ) ) { 74 return $myredis->executeRaw( ['DEL', $key ] ); 92 if( $redis_api == 'predis') { 93 return $myredis->executeRaw( ['DEL', $key ] ); 94 } else if( $redis_api == 'php-redis') { 95 return $myredis->del( $key ); 96 } 75 97 } else { 76 98 return false; … … 85 107 function delete_keys_by_wildcard( $pattern ) 86 108 { 87 global $myredis, $lua ;109 global $myredis, $lua, $redis_api; 88 110 /* 89 111 Lua Script block to delete multiple keys using wildcard … … 95 117 Call redis eval and return value from lua script 96 118 */ 97 if ( !empty( $myredis ) ) { 98 return $myredis->eval( $lua, 1, $pattern ); 99 } else { 119 if ( ! empty( $myredis ) ) { 120 if( $redis_api == 'predis') { 121 return $myredis->eval( $lua, 1, $pattern ); 122 } else if( $redis_api == 'php-redis') { 123 return $myredis->eval( $lua, array( $pattern ), 1 ); 124 } 125 } else { 100 126 return false; 101 127 } -
nginx-helper/trunk/nginx-helper.php
r1191882 r1196126 3 3 Plugin Name: Nginx Helper 4 4 Plugin URI: https://rtcamp.com/nginx-helper/ 5 Description: Cleans nginx's fastcgi/proxy cache whenever a post is edited/published. Also does few more things.6 Version: 1.9. 25 Description: Cleans nginx's fastcgi/proxy cache or redis-cahce whenever a post is edited/published. Also does few more things. 6 Version: 1.9.3 7 7 Author: rtCamp 8 8 Author URI: https://rtcamp.com … … 129 129 $skip_status = array( 'auto-draft', 'draft', 'inherit', 'trash', 'pending' ); 130 130 $purge_status = array( 'publish', 'future' ); 131 131 132 132 if ( !$this->options['enable_purge'] || in_array( $old_status, $skip_status ) ) { 133 133 return; 134 134 } 135 135 136 136 if( in_array( $old_status, $purge_status ) || in_array( $new_status, $purge_status ) ) { 137 137 $rt_wp_nginx_purger->log( "Purge post on transition post STATUS from " . $old_status . " to " . $new_status ); -
nginx-helper/trunk/readme.txt
r1191882 r1196126 1 1 === Nginx Helper === 2 Contributors: rtcamp, rahul286, saurabhshukla, manishsongirkar36, faishal, desaiuditd, Darren Slatten, jk3us, daankortenbach, telofy, pjv, llonchj, jinnko, weskoop, bcole808, gungeekatx, rohanveer, chandrapatel3 Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, re write, permalinks2 Contributors: rtcamp, rahul286, saurabhshukla, manishsongirkar36, faishal, desaiuditd, darren-slatten, jk3us, daankortenbach, telofy, pjv, llonchj, jinnko, weskoop, bcole808, gungeekatx, rohanveer, chandrapatel, gagan0123 3 Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, redis, redis-cache, rewrite, permalinks 4 4 Requires at least: 3.0 5 5 Tested up to: 4.2.2 6 Stable tag: 1.9.2 7 later (of-.1course) 8 Fix purging for custom post types 9 6 Stable tag: 1.9.3 10 7 License: GPLv2 or later (of-course) 11 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html 12 9 Donate Link: http://rtcamp.com/donate/ 13 10 14 Cleans nginx's fastcgi/proxy cache whenever a post is edited/published. Also does afew more things.11 Cleans nginx's fastcgi/proxy cache or redis-cahce whenever a post is edited/published. Also does few more things. 15 12 16 13 == Description == 17 14 18 15 1. Removes `index.php` from permalinks when using WordPress with nginx. 16 1. Adds support for purging redis-cache when used as full-page cache created using [nginx-srcache-module](https://github.com/openresty/srcache-nginx-module#caching-with-redis) 19 17 1. Adds support for nginx fastcgi_cache_purge & proxy_cache_purge directive from [module](https://github.com/FRiCKLE/ngx_cache_purge "ngx_cache_purge module"). Provides settings so you can customize purging rules. 20 18 1. Adds support for nginx `map{..}` on a WordPress-multisite network installation. Using it, Nginx can serve PHP file uploads even if PHP/MySQL crashes. Please check the tutorial list below for related Nginx configurations. … … 117 115 == Changelog == 118 116 117 = 1.9.3 = 118 * Added PhpRedis API support. 119 * Added redis-lua script support to purge complete cache very fast. 120 * Added composer.json support 121 * Fixed cache purging link in admin bar. 122 * Updated the initial settings to include the 'purge_method' [#99](https://github.com/rtCamp/nginx-helper/pull/99) - by 123 [gagan0123](https://github.com/gagan0123) 124 119 125 = 1.9.2 = 120 126 Fix purging for Redis cache and FastCGI cache … … 306 312 == Upgrade Notice == 307 313 308 = 1.9 = 309 Added Redis cache purge support. 314 = 1.9.3 = 315 * Added PhpRedis API support. 316 * Fixed cache purging link in admin bar. -
nginx-helper/trunk/redis-purger.php
r1191882 r1196126 663 663 $this->log( "* Purged Everything!" ); 664 664 $this->log( "* * * * *" ); 665 delete_multi_keys("*"); 666 } 665 //delete_multi_keys("*"); 666 delete_keys_by_wildcard("*"); 667 } 667 668 668 669 } -
nginx-helper/trunk/tests/functional/src/purge-method-get-request-page-test.js
r1190839 r1196126 54 54 .url(data.URLS.LOGIN + urlp) 55 55 .click('.post-edit-link') 56 57 .clearValue('textarea[id="content"]') 58 .setValue('textarea[id="content"]', "test page content updated") 56 .clearValue('#title') 57 .setValue('#title', "test page title updated") 59 58 .click('#publish') 59 .pause(2000) 60 60 .wplogout() 61 61 .url(data.URLS.LOGIN + urlp) 62 .assert.containsText("#main", "test page content updated") 62 .verify.containsText(".entry-title", "test page title updated") 63 .verify.containsText(".site-main", "test page created for testing") 63 64 }, 64 65 -
nginx-helper/trunk/tests/functional/src/purge-method-unlink-files-page-test.js
r1190839 r1196126 54 54 .url(data.URLS.LOGIN + urlp) 55 55 .click('.post-edit-link') 56 57 .clearValue('textarea[id="content"]') 58 .setValue('textarea[id="content"]', "test page content updated") 56 .clearValue('#title') 57 .setValue('#title', "test page title updated") 59 58 .click('#publish') 59 .pause(2000) 60 60 .wplogout() 61 61 .url(data.URLS.LOGIN + urlp) 62 .assert.containsText("#main", "test page content updated") 62 .verify.containsText(".entry-title", "test page title updated") 63 .verify.containsText(".site-main", "test page created for testing") 63 64 }, 64 65
Note: See TracChangeset
for help on using the changeset viewer.