-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Cache Drive Backups #2060
Cache Drive Backups #2060
Conversation
…dummy' handler if $adapter->initialize() throws a CriticalError. RedisHandler throws a CriticalError if there is an issue connecting to Redis.
Was originally pull request #2057, but i had some issues... So here it is again (Working this time hopefully). |
I like the idea of this a lot. I made one comment on the code, but could you add the same process to the other drivers? |
…to mimic RedisHandler.php and PredisHandler.php
Added connection checker for when \Memcache is used.
@lonnieezell I've attempted to implement a similar process for the other drives as requested. The DummyHander, FileHander and WincacheHandler's initialize() method contain no logic, so I have ignored these. I modelled my solution on how PredisHandler initialize() method, so I've just added some comments there. I've changed MemcachedHandler initialize() a fair bit, I've broken it down into two sections contained within the if/elseif block. I've tested the Redis, Predis, Memcached drivers and I'm happy with how they work (If they can't connect to the cache server, they throw a CriticalError exception). I'm unable to test the Memcache driver (I can't seem to get it to work with PHP 7+). I'm confident with the code I've written to check if the cache server is contactable when using Memcache, I followed https://www.php.net/manual/en/memcache.connect.php, which suggests that if connect() returns false, the sever can not be contacted, which will trigger our CriticalError exception. Is it worth performing similar checks on the Handlers I've ignored? Or does the isSupported() method handle it? |
I believe isSupported should be sufficient, but it's been a while since I've been in those handlers, honestly. Thanks for this! In the future, though, we would prefer to have signed commits. There's instructions in the docs to help with that. |
Description
If our application is unable to connect to Redis, a CriticalError exception is now thrown.
CacheFactory catches the CriticalError exceptions that are thrown when Redis, Memcache and Predis fail to connect, it logs the exception and then attempts to initialize the backup cache driver (and if that fails it initializes dummy).
Checklist: