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

Better handling when Redis is enabled, but unavailable or gone away #18

Merged
merged 6 commits into from
Oct 31, 2015

Conversation

danielbachhuber
Copy link
Contributor

  1. Remove the WP_Redis class. Because we're wrapping calls to Redis
    internally, we don't need a mock equivalent of the Redis class.
  2. Distinguish error message between Redis not installed and Redis
    unavailable.
  3. Attempt to refresh the connection the first time the connection has gone away.
  4. Fall back to the WP object cache when the connection isn't recoverable.

See #4, #8, #9

* Remove the `WP_Redis` class. Because we're wrapping calls to Redis
  internally, we don't need a mock equivalent of the `Redis` class.
* Distinguish error message between Redis not installed and Redis
  unavailable.
@danielbachhuber danielbachhuber added this to the v0.2.0 milestone Oct 30, 2015
}
} else {
class WP_Redis {
protected function _call_redis( $method ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a huge fan of prefixing methods with _, but the pattern is already established with _exists

`_call_redis()` checks our `is_redis_connected` class variable, which is
set to false. We don't need the safety fallback here
Redis can go away on occasion. We want to make sure the relationship
doesn't completely end.
@danielbachhuber danielbachhuber changed the title Wrap calls to Redis so we can catch exceptions when Redis has gone away Better handling when Redis is enabled, but unavailable or gone away Oct 30, 2015
$this->blog_prefix = $this->multisite ? $blog_id . ':' : '';
if ( ! class_exists( 'Redis' ) ) {
$this->is_redis_connected = false;
$this->missing_redis_message = 'Alert! PHPRedis module is unavailable, which is required by WP Redis object cache.';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshkoenig How do you feel about the language in this string?

@@ -769,18 +782,54 @@ public function __call( $name, $arguments ) {
case 'exists':
return false;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would still be super-helpful to be able to (optionally) log failures here. i.e. https://github.com/pantheon-systems/wp-redis/pull/5/files#diff-5a2b681f0d32956de83215ea32388177R755

@joshkoenig
Copy link
Member

Language looks good to me.

joshkoenig pushed a commit that referenced this pull request Oct 31, 2015
…back

Better handling when Redis is enabled, but unavailable or gone away
@joshkoenig joshkoenig merged commit f3502b6 into master Oct 31, 2015
@jtsternberg
Copy link

Please consider that logging will likely be necessary in the event of Redis server failures: #18 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants