bzcomputers
Well-known member
I think this would be on XF to redesign the way they do caching, not this add-on.
if it can't pull from the cache after a retry, it should compute/pull direct and send an alert of some sort "Hey admin, cache hit failed at X time".
Yes, I agree. I just wanted to reconfirm with @Xon that my expectations that XenForo should fallback gracefully if Redis (or any caching instance) wasn't out of line before moving on to report this "bug" with caching.
Edit: From what I can tell the fatal CredisException is thrown directly from Credis_Client->connect() inside the add-on’s code (Client.php line ~607).The add-on is the one deciding how to handle (or not handle) connection failures. SV\RedisCache\SymfonyCache\Redis.php is already intercepting calls (e.g., getItems, mGet) and timing them. It would be straightforward for the add-on to wrap the initial connect() call in a try/catch block and, on failure, return a fallback cache provider (e.g., a NullCache, ArrayCache, or XenForo’s default FileCache).
XenForo expects the cache object (from config['cache']['provider']) to behave like PSR-16 SimpleCache — i.e., it should never throw exceptions on get/set/delete when the backend is unavailable; it should return null/false or a default value gracefully.Most production Redis cache libraries (e.g., Symfony’s RedisAdapter, Laravel’s Redis store) do exactly that: they catch connection errors and degrade silently or fall back. Credis itself is quite low-level and throws aggressively — that would make this add-on responsible for adding that resilience layer.
Something like...
PHP:
public function getItems(array $keys)
{
try {
if (!$this->redis->isConnected()) {
$this->redis->connect(...); // or reconnect logic
}
return $this->redis->mGet($keys);
} catch (CredisException $e) {
// Log once: "Redis unavailable, falling back to file cache"
$this->fallbackCache = $this->createFallbackCache(); // e.g. FileCache or NullCache
return $this->fallbackCache->getItems($keys);
}
}
// Similar try/catch around set, delete, clear, has, etc.
This could be done on first failure, then to fallback and stay there until Redis is detected alive again (periodic health check). This would prevent the site-wide fatals like I experienced during Redis restarts/outages.
Last edited: