Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use flushdb instead of flushAll #259

Merged
merged 3 commits into from
Dec 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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