|
|
@@ -15,8 +15,9 @@
|
|
|
namespace Cake\Cache;
|
|
|
|
|
|
use Cake\Cache\Engine\NullEngine;
|
|
|
-use Cake\Core\Exception\Exception;
|
|
|
use Cake\Core\StaticConfigTrait;
|
|
|
+use InvalidArgumentException;
|
|
|
+use RuntimeException;
|
|
|
|
|
|
/**
|
|
|
* Cache provides a consistent interface to Caching in your application. It allows you
|
|
|
@@ -61,7 +62,6 @@ use Cake\Core\StaticConfigTrait;
|
|
|
* @param string $name Name of the configuration
|
|
|
* @param array $config Optional associative array of settings passed to the engine
|
|
|
* @return array [engine, settings] on success, false on failure
|
|
|
- * @throws \Cake\Core\Exception\Exception
|
|
|
*/
|
|
|
class Cache {
|
|
|
|
|
|
@@ -100,14 +100,17 @@ class Cache {
|
|
|
*
|
|
|
* @param string $name Name of the config array that needs an engine instance built
|
|
|
* @return void
|
|
|
- * @throws \Cake\Core\Exception\Exception When a cache engine cannot be created.
|
|
|
+ * @throws \InvalidArgumentException When a cache engine cannot be created.
|
|
|
*/
|
|
|
protected static function _buildEngine($name) {
|
|
|
if (empty(static::$_registry)) {
|
|
|
static::$_registry = new CacheRegistry();
|
|
|
}
|
|
|
+
|
|
|
if (empty(static::$_config[$name]['className'])) {
|
|
|
- throw new Exception(sprintf('The "%s" cache configuration does not exist.', $name));
|
|
|
+ throw new InvalidArgumentException(
|
|
|
+ sprintf('The "%s" cache configuration does not exist.', $name)
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
$config = static::$_config[$name];
|
|
|
@@ -213,14 +216,14 @@ class Cache {
|
|
|
* @param array $data An array of data to be stored in the cache
|
|
|
* @param string $config Optional string configuration name to write to. Defaults to 'default'
|
|
|
* @return array of bools for each key provided, indicating true for success or false for fail
|
|
|
- * @throws Cake\Core\Exception\Exception
|
|
|
+ * @throws RuntimeException
|
|
|
*/
|
|
|
public static function writeMany($data, $config = 'default') {
|
|
|
$engine = static::engine($config);
|
|
|
$return = $engine->writeMany($data);
|
|
|
foreach ($return as $key => $success) {
|
|
|
if ($success === false && !empty($data[$key])) {
|
|
|
- throw new Exception(sprintf(
|
|
|
+ throw new RuntimeException(sprintf(
|
|
|
'%s cache was unable to write \'%s\' to %s cache',
|
|
|
$config,
|
|
|
$key,
|
|
|
@@ -394,7 +397,7 @@ class Cache {
|
|
|
*
|
|
|
* @param string $group group name or null to retrieve all group mappings
|
|
|
* @return array map of group and all configuration that has the same group
|
|
|
- * @throws \Cake\Core\Exception\Exception
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
*/
|
|
|
public static function groupConfigs($group = null) {
|
|
|
if ($group === null) {
|
|
|
@@ -405,7 +408,7 @@ class Cache {
|
|
|
return [$group => self::$_groups[$group]];
|
|
|
}
|
|
|
|
|
|
- throw new Exception(sprintf('Invalid cache group %s', $group));
|
|
|
+ throw new InvalidArgumentException(sprintf('Invalid cache group %s', $group));
|
|
|
}
|
|
|
|
|
|
/**
|