What you can do is try to get an instance (\ Redis :: instance ()) and work with it like this:
try { $redis = \Redis::instance(); // Do something with Redis. } catch(\RedisException $e) { // Fall back to other db usage. }
But it is advisable that you know if Redis is working or not. This is just a way to discover it on the fly.
source share