Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab8fa7d

Browse files
Use a static variable for our nodemap file and only open it once
to avoid blowing file descriptors.
1 parent 9f865c1 commit ab8fa7d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

tests/RedisClusterTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* where we're validating specific cluster mechanisms
88
*/
99
class Redis_Cluster_Test extends Redis_Test {
10-
private $_arr_node_map = Array();
10+
private static $_arr_node_map = Array();
1111

1212
private $_arr_redis_types = Array(
1313
Redis::REDIS_STRING,
@@ -43,9 +43,11 @@ public function __construct() {
4343
}
4444

4545
/* Store our node map */
46-
$this->_arr_node_map = array_filter(
47-
explode("\n", file_get_contents($str_nodemap_file)
48-
));
46+
if (!self::$_arr_node_map) {
47+
self::$_arr_node_map = array_filter(
48+
explode("\n", file_get_contents($str_nodemap_file)
49+
));
50+
}
4951
}
5052

5153
/* Override setUp to get info from a specific node */
@@ -57,7 +59,7 @@ public function setUp() {
5759

5860
/* Override newInstance as we want a RedisCluster object */
5961
protected function newInstance() {
60-
return new RedisCluster(NULL, $this->_arr_node_map);
62+
return new RedisCluster(NULL, self::$_arr_node_map);
6163
}
6264

6365
/* Overrides for RedisTest where the function signature is different. This

tests/TestSuite.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,8 @@ public static function run($className, $str_limit = NULL) {
147147
if ($e instanceof RedisException) {
148148
$className::$errors[] = "Uncaught exception '".$e->getMessage()."' ($name)\n";
149149
$str_msg = self::make_fail('FAILED');
150-
//echo 'F';
151150
} else {
152151
$str_msg = self::make_warning('SKIPPED');
153-
//echo 'S';
154152
}
155153
}
156154

0 commit comments

Comments
 (0)