Skip to content

Commit

Permalink
Merge pull request #259 from pantheon-systems/258-use-flush-db
Browse files Browse the repository at this point in the history
Use `flushdb` instead of `flushAll`
  • Loading branch information
danielbachhuber authored Dec 19, 2019
2 parents bd4eba7 + ce030fd commit a226875
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ There's a known issue with WordPress `alloptions` cache design. Specifically, a

## Changelog ##

### 0.8.0 (Unreleased) ###
* Uses `flushdb` instead of `flushAll` to avoid flushing the entire Redis instance [[#259](https://github.com/pantheon-systems/wp-redis/pull/259)].

### 0.7.1 (December 14, 2018) ###
* Better support in `wp_cache_init()` for drop-ins like LudicrousDB [[#231](https://github.com/pantheon-systems/wp-redis/pull/231)].
* Cleans up PHPCS issues.
Expand Down
4 changes: 2 additions & 2 deletions bin/install-wp-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ install_test_suite() {
if [ ! -d $WP_TESTS_DIR ]; then
# set up testing suite
mkdir -p $WP_TESTS_DIR
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
svn co --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
svn co --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
fi

if [ ! -f wp-tests-config.php ]; then
Expand Down
2 changes: 1 addition & 1 deletion object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public function delete_group( $group ) {
public function flush( $redis = true ) {
$this->cache = array();
if ( $redis ) {
$this->_call_redis( 'flushAll' );
$this->_call_redis( 'flushdb' );
}

return true;
Expand Down
3 changes: 3 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ There's a known issue with WordPress `alloptions` cache design. Specifically, a

== Changelog ==

= 0.8.0 (Unreleased) =
* Uses `flushdb` instead of `flushAll` to avoid flushing the entire Redis instance [[#259](https://github.com/pantheon-systems/wp-redis/pull/259)].

= 0.7.1 (December 14, 2018) =
* Better support in `wp_cache_init()` for drop-ins like LudicrousDB [[#231](https://github.com/pantheon-systems/wp-redis/pull/231)].
* Cleans up PHPCS issues.
Expand Down
3 changes: 2 additions & 1 deletion tests/phpunit/test-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function setUp() {
// 'hIncrBy' isn't a typo here — Redis doesn't support decrBy on groups
self::$decr_by_key = WP_Object_Cache::USE_GROUPS ? 'hIncrBy' : 'decrBy';
self::$delete_key = WP_Object_Cache::USE_GROUPS ? 'hDel' : 'del';
self::$flush_all_key = 'flushAll';
self::$flush_all_key = 'flushdb';

}

Expand Down Expand Up @@ -1262,6 +1262,7 @@ public function test_redis_connect_custom_database() {
}
$redis_server['database'] = 2;
$second_cache = new WP_Object_Cache;
$second_cache->flush(); // Make sure it's in pristine state.
$this->cache->set( 'foo', 'bar' );
$this->assertEquals( 'bar', $this->cache->get( 'foo' ) );
$this->assertFalse( $second_cache->get( 'foo' ) );
Expand Down
2 changes: 1 addition & 1 deletion wp-redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WP Redis
* Plugin URI: http://github.com/pantheon-systems/wp-redis/
* Description: WordPress Object Cache using Redis. Requires the PhpRedis extension (https://github.com/phpredis/phpredis).
* Version: 0.7.1
* Version: 0.8.0-alpha
* Author: Pantheon, Josh Koenig, Matthew Boynes, Daniel Bachhuber, Alley Interactive
* Author URI: https://pantheon.io/
*/
Expand Down

0 comments on commit a226875

Please sign in to comment.