/** * @inheritdoc * * @throws InvalidConfigException */ public function init() { parent::init(); if ($this->folder === NULL) { throw new InvalidConfigException('FolderDependency::$folder must be set'); } if (!is_array($this->folder)) { $this->folder = (array) $this->folder; } if (!$this->folder) { throw new InvalidConfigException('FolderDependency::$folder must be the path to the folder'); } foreach ($this->folder as $i => $folder) { $folder = FileHelper::normalizePath(Yii::getAlias($folder)); if (!is_dir($folder)) { throw new InvalidConfigException('FolderDependency::$folder must be the path to the folder'); } $this->folder[$i] = $folder; } }
/** * Stores a value identified by a key into cache if the cache does not contain this key. * Nothing will be done if the cache already contains the key. * @param mixed $key a key identifying the value to be cached. This can be a simple string or * a complex data structure consisting of factors representing the key. * @param mixed $value the value to be cached * @param integer $duration the number of seconds in which the cached value will expire. 0 means never expire. * @param Dependency $dependency dependency of the cached item. If the dependency changes, * the corresponding value in the cache will be invalidated when it is fetched via [[get()]]. * This parameter is ignored if [[serializer]] is false. * @return boolean whether the value is successfully stored into cache */ public function add($key, $value, $duration = 0, $dependency = null) { if ($dependency !== null && $this->serializer !== false) { $dependency->evaluateDependency($this); } if ($this->serializer === null) { $value = serialize([$value, $dependency]); } elseif ($this->serializer !== false) { $value = call_user_func($this->serializer[0], [$value, $dependency]); } $key = $this->buildKey($key); return $this->addValue($key, $value, $duration); }
/** * [[@doctodo method_description:clearCaches]]. */ public function clearCaches() { ActiveRecord::clearCache(); \yii\caching\Dependency::resetReusableData(); \cascade\components\types\Relationship::clearCache(); }