Nginx Helper - Version 1.9.4

Version Description

  • Added redis server connection timeout.
  • Added RedisException handling.
Download this release

Release Info

Developer rtcamp
Plugin Icon 128x128 Nginx Helper
Version 1.9.4
Comparing to
See all releases

Code changes from version 1.9.3 to 1.9.4

Files changed (4) hide show
  1. composer.json +11 -3
  2. includes/redis-delete.php +49 -41
  3. nginx-helper.php +2 -2
  4. readme.txt +9 -5
composer.json CHANGED
@@ -3,16 +3,24 @@
3
  "description": "Cleans nginx's fastcgi/proxy cache or redis-cahce whenever a post is edited/published. Also does few more things.",
4
  "keywords": ["wordpress", "plugin", "nginx", "nginx-helper", "fastcgi", "redis-cahce", "redis", "cache"],
5
  "homepage": "https://rtcamp.com/nginx-helper/",
6
- "license": "GPLv2",
7
  "authors": [{
8
  "name": "rtCamp",
9
- "email": "admin@rtcamp.com",
10
  "homepage": "https://rtcamp.com"
11
  }],
 
 
12
  "type": "wordpress-plugin",
 
 
 
 
 
 
13
  "require": {
14
  "php": ">=5.3.2",
15
- "composer/installers": "v1.0.6"
16
  },
17
  "require-dev": {
18
  "wpreadme2markdown/wpreadme2markdown": "*"
3
  "description": "Cleans nginx's fastcgi/proxy cache or redis-cahce whenever a post is edited/published. Also does few more things.",
4
  "keywords": ["wordpress", "plugin", "nginx", "nginx-helper", "fastcgi", "redis-cahce", "redis", "cache"],
5
  "homepage": "https://rtcamp.com/nginx-helper/",
6
+ "license": "GPL-2.0+",
7
  "authors": [{
8
  "name": "rtCamp",
9
+ "email": "support@rtcamp.com",
10
  "homepage": "https://rtcamp.com"
11
  }],
12
+ "minimum-stability": "dev",
13
+ "prefer-stable": true,
14
  "type": "wordpress-plugin",
15
+ "support": {
16
+ "issues": "https://github.com/rtCamp/nginx-helper/issues",
17
+ "forum": "https://wordpress.org/support/plugin/nginx-helper",
18
+ "wiki": "https://github.com/rtCamp/nginx-helper/wiki",
19
+ "source": "https://github.com/rtCamp/nginx-helper/"
20
+ },
21
  "require": {
22
  "php": ">=5.3.2",
23
+ "composer/installers": "^1.0"
24
  },
25
  "require-dev": {
26
  "wpreadme2markdown/wpreadme2markdown": "*"
includes/redis-delete.php CHANGED
@@ -3,7 +3,7 @@
3
  //TODO:: phpRedis based implementation https://github.com/phpredis/phpredis#eval
4
  //include predis (php implementation for redis)
5
 
6
- global $myredis, $rt_wp_nginx_helper, $redis_api, $lua;
7
 
8
  $host = $rt_wp_nginx_helper->options['redis_hostname'];
9
  $port = $rt_wp_nginx_helper->options['redis_port'];
@@ -12,9 +12,9 @@ $redis_api = '';
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';
@@ -30,7 +30,7 @@ if ( class_exists( 'Redis' ) ) { // Use PHP5-Redis if installed.
30
  try {
31
  $myredis->connect();
32
  $redis_api = 'predis';
33
- } catch ( Exception $e ) {}
34
  }
35
 
36
  //Lua Script
@@ -49,20 +49,23 @@ LUA;
49
  */
50
 
51
  function delete_multi_keys( $key )
52
- {
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
- }
66
  }
67
 
68
  /*
@@ -71,12 +74,14 @@ function delete_multi_keys( $key )
71
 
72
  function flush_entire_db()
73
  {
74
- global $myredis;
75
- if ( !empty( $myredis ) ) {
76
- return $myredis->flushdb();
77
- } else {
78
- return false;
79
- }
 
 
80
  }
81
 
82
  /*
@@ -86,17 +91,18 @@ function flush_entire_db()
86
 
87
  function delete_single_key( $key )
88
  {
89
- global $myredis, $redis_api;
90
-
91
- if ( !empty( $myredis ) ) {
92
- if( $redis_api == 'predis') {
93
- return $myredis->executeRaw( ['DEL', $key ] );
94
- } else if( $redis_api == 'php-redis') {
95
- return $myredis->del( $key );
 
 
 
96
  }
97
- } else {
98
- return false;
99
- }
100
  }
101
 
102
  /*
@@ -106,7 +112,7 @@ function delete_single_key( $key )
106
 
107
  function delete_keys_by_wildcard( $pattern )
108
  {
109
- global $myredis, $lua, $redis_api;
110
  /*
111
  Lua Script block to delete multiple keys using wildcard
112
  Script will return count i.e. number of keys deleted
@@ -116,15 +122,17 @@ function delete_keys_by_wildcard( $pattern )
116
  /*
117
  Call redis eval and return value from lua script
118
  */
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 {
126
- return false;
127
- }
128
  }
129
 
130
  ?>
3
  //TODO:: phpRedis based implementation https://github.com/phpredis/phpredis#eval
4
  //include predis (php implementation for redis)
5
 
6
+ global $myredis, $rt_wp_nginx_helper, $redis_api, $lua, $rt_wp_nginx_purger;
7
 
8
  $host = $rt_wp_nginx_helper->options['redis_hostname'];
9
  $port = $rt_wp_nginx_helper->options['redis_port'];
12
  if ( class_exists( 'Redis' ) ) { // Use PHP5-Redis if installed.
13
  try {
14
  $myredis = new Redis();
15
+ $myredis->connect( $host, $port, 5 );
16
  $redis_api = 'php-redis';
17
+ } catch ( Exception $e ) { $rt_wp_nginx_purger->log( $e->getMessage(), 'ERROR' ); }
18
  } else {
19
  if( ! class_exists( 'Predis\Autoloader' ) ) {
20
  require_once 'predis.php';
30
  try {
31
  $myredis->connect();
32
  $redis_api = 'predis';
33
+ } catch ( Exception $e ) { $rt_wp_nginx_purger->log( $e->getMessage(), 'ERROR' ); }
34
  }
35
 
36
  //Lua Script
49
  */
50
 
51
  function delete_multi_keys( $key )
52
+ {
53
+ global $myredis, $redis_api, $rt_wp_nginx_purger;
54
+
55
+ try {
56
+ if ( !empty( $myredis ) ) {
57
+ $matching_keys = $myredis->keys( $key );
58
+ if( $redis_api == 'predis') {
59
+ foreach ( $matching_keys as $key => $value ) {
60
+ $myredis->executeRaw( ['DEL', $value ] );
61
+ }
62
+ } else if( $redis_api == 'php-redis') {
63
+ return $myredis->del( $matching_keys );
64
  }
65
+ } else {
66
+ return false;
67
  }
68
+ } catch ( Exception $e ) { $rt_wp_nginx_purger->log( $e->getMessage(), 'ERROR' ); }
 
 
69
  }
70
 
71
  /*
74
 
75
  function flush_entire_db()
76
  {
77
+ global $myredis, $rt_wp_nginx_purger;
78
+ try {
79
+ if ( !empty( $myredis ) ) {
80
+ return $myredis->flushdb();
81
+ } else {
82
+ return false;
83
+ }
84
+ } catch ( Exception $e ) { $rt_wp_nginx_purger->log( $e->getMessage(), 'ERROR' ); }
85
  }
86
 
87
  /*
91
 
92
  function delete_single_key( $key )
93
  {
94
+ global $myredis, $redis_api, $rt_wp_nginx_purger;
95
+ try {
96
+ if ( !empty( $myredis ) ) {
97
+ if( $redis_api == 'predis') {
98
+ return $myredis->executeRaw( ['DEL', $key ] );
99
+ } else if( $redis_api == 'php-redis') {
100
+ return $myredis->del( $key );
101
+ }
102
+ } else {
103
+ return false;
104
  }
105
+ } catch ( Exception $e ) { $rt_wp_nginx_purger->log( $e->getMessage(), 'ERROR' ); }
 
 
106
  }
107
 
108
  /*
112
 
113
  function delete_keys_by_wildcard( $pattern )
114
  {
115
+ global $myredis, $lua, $redis_api, $rt_wp_nginx_purger;
116
  /*
117
  Lua Script block to delete multiple keys using wildcard
118
  Script will return count i.e. number of keys deleted
122
  /*
123
  Call redis eval and return value from lua script
124
  */
125
+ try {
126
+ if ( ! empty( $myredis ) ) {
127
+ if( $redis_api == 'predis') {
128
+ return $myredis->eval( $lua, 1, $pattern );
129
+ } else if( $redis_api == 'php-redis') {
130
+ return $myredis->eval( $lua, array( $pattern ), 1 );
131
+ }
132
+ } else {
133
+ return false;
134
  }
135
+ } catch ( Exception $e ) { $rt_wp_nginx_purger->log( $e->getMessage(), 'ERROR' ); }
 
 
136
  }
137
 
138
  ?>
nginx-helper.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
3
  Plugin Name: Nginx Helper
4
  Plugin URI: https://rtcamp.com/nginx-helper/
5
- 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
  Author: rtCamp
8
  Author URI: https://rtcamp.com
9
  Text Domain: nginx-helper
2
  /*
3
  Plugin Name: Nginx Helper
4
  Plugin URI: https://rtcamp.com/nginx-helper/
5
+ Description: Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does few more things.
6
+ Version: 1.9.4
7
  Author: rtCamp
8
  Author URI: https://rtcamp.com
9
  Text Domain: nginx-helper
readme.txt CHANGED
@@ -3,12 +3,12 @@ Contributors: rtcamp, rahul286, saurabhshukla, manishsongirkar36, faishal, desai
3
  Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, redis, redis-cache, rewrite, permalinks
4
  Requires at least: 3.0
5
  Tested up to: 4.2.2
6
- Stable tag: 1.9.3
7
  License: GPLv2 or later (of-course)
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Donate Link: http://rtcamp.com/donate/
10
 
11
- Cleans nginx's fastcgi/proxy cache or redis-cahce whenever a post is edited/published. Also does few more things.
12
 
13
  == Description ==
14
 
@@ -114,6 +114,10 @@ Please post your problem in [our free support forum](http://community.rtcamp.com
114
 
115
  == Changelog ==
116
 
 
 
 
 
117
  = 1.9.3 =
118
  * Added PhpRedis API support.
119
  * Added redis-lua script support to purge complete cache very fast.
@@ -311,6 +315,6 @@ Fix url escaping [#82](https://github.com/rtCamp/nginx-helper/pull/82) - by
311
 
312
  == Upgrade Notice ==
313
 
314
- = 1.9.3 =
315
- * Added PhpRedis API support.
316
- * Fixed cache purging link in admin bar.
3
  Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, redis, redis-cache, rewrite, permalinks
4
  Requires at least: 3.0
5
  Tested up to: 4.2.2
6
+ Stable tag: 1.9.4
7
  License: GPLv2 or later (of-course)
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Donate Link: http://rtcamp.com/donate/
10
 
11
+ Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does few more things.
12
 
13
  == Description ==
14
 
114
 
115
  == Changelog ==
116
 
117
+ = 1.9.4 =
118
+ * Added redis server connection timeout.
119
+ * Added RedisException handling.
120
+
121
  = 1.9.3 =
122
  * Added PhpRedis API support.
123
  * Added redis-lua script support to purge complete cache very fast.
315
 
316
  == Upgrade Notice ==
317
 
318
+ = 1.9.4 =
319
+ * Added redis server connection timeout.
320
+ * Added RedisException handling.