/** * Устанавливает значение кэша для плагина * * @param string $plugin Название плагина * @param \Phalcon\Http\Request $request Запрос * @param array $result Значение */ public function set($plugin, Request $request, $result) { if (!$this->useCache()) { return; } $key = $this->getCacheKey($plugin, $request); return $this->cache->save($key, $result); }
public function __destruct() { if ($this->_data == null) { return; } foreach ($this->_data as $key => $value) { if ($value != null) { $this->cache->save($key, $value); } } $this->_data = null; }
/** * Prints the HTML for CSS resources. * * @param string $collectionName the name of the collection * * @return string **/ public function outputCss($collectionName = self::DEFAULT_COLLECTION_CSS) { $remote = $this->_config->application->assets->get('remote'); $collection = $this->collection($collectionName); if (!$remote && $collection->getJoin()) { $local = $this->_config->application->assets->get('local'); $lifetime = $this->_config->application->assets->get('lifetime', 0); $filepath = $local . self::GENERATED_STORAGE_PATH . ($filename = $filename = $this->getCollectionFileName($collection, self::FILENAME_PATTERN_CSS)); $collection->setTargetPath($filepath)->setTargetUri($filepath); if ($this->_cache->exists($filename)) { return Tag::stylesheetLink($collection->getTargetUri()); } $res = parent::outputCss($collectionName); $this->_cache->save($filename, true, $lifetime); return $res; } return parent::outputCss($collectionName); }
public function reset($keyName) { $this->cache->save($this->prefix . $keyName, 0); }
public static function set($key, $value, $ttl = null) { static::$cache === null and static::$cache = static::$di->getShared('cache'); static::$cache->save($key, $value, $ttl); }