mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
assert that the cache does not silently fail
This commit is contained in:
parent
967526540a
commit
05167a6420
1 changed files with 7 additions and 7 deletions
|
@ -154,21 +154,21 @@ class Cache {
|
|||
$cacheClass = $class . 'Engine';
|
||||
App::uses($cacheClass, $plugin . 'Cache/Engine');
|
||||
if (!class_exists($cacheClass)) {
|
||||
return false;
|
||||
throw new CacheException(__d('cake_dev', 'Cache engine %s is not available.', $name));
|
||||
}
|
||||
$cacheClass = $class . 'Engine';
|
||||
if (!is_subclass_of($cacheClass, 'CacheEngine')) {
|
||||
throw new CacheException(__d('cake_dev', 'Cache engines must use CacheEngine as a base class.'));
|
||||
}
|
||||
self::$_engines[$name] = new $cacheClass();
|
||||
if (self::$_engines[$name]->init($config)) {
|
||||
if (!self::$_engines[$name]->init($config)) {
|
||||
throw new CacheException(__d('cake_dev', 'Cache engine %s is not properly configured.', $name));
|
||||
}
|
||||
if (self::$_engines[$name]->settings['probability'] && time() % self::$_engines[$name]->settings['probability'] === 0) {
|
||||
self::$_engines[$name]->gc();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing the currently configured Cache settings.
|
||||
|
|
Loading…
Reference in a new issue