not only check for redis extension during driver load

This commit is contained in:
HB9HIL
2026-02-02 12:57:31 +01:00
parent 4d23c75781
commit 823148c752

View File

@@ -102,7 +102,7 @@ class CI_Cache_redis extends CI_Driver
{
if ( ! $this->is_supported())
{
log_message('error', 'Cache: Failed to create Redis object; extension not loaded?');
log_message('error', 'Cache: Failed to create Redis object; extension not loaded or redis not available?');
return;
}
@@ -339,7 +339,25 @@ class CI_Cache_redis extends CI_Driver
*/
public function is_supported()
{
return extension_loaded('redis');
if ( ! extension_loaded('redis'))
{
return FALSE;
}
if ( ! isset($this->_redis))
{
return FALSE;
}
try
{
return $this->_redis->ping();
}
catch (Exception $e)
{
log_message('debug', 'Cache: Redis ping failed - '.$e->getMessage());
return FALSE;
}
}
// ------------------------------------------------------------------------