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 preferably you'd know whether redis is running or not. This is just the way to detect it on the fly.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…