当前位置: 首页>>代码示例>>PHP>>正文


PHP Cache::save方法代码示例

本文整理汇总了PHP中Nette\Caching\Cache::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::save方法的具体用法?PHP Cache::save怎么用?PHP Cache::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Caching\Cache的用法示例。


在下文中一共展示了Cache::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getClass

 /**
  * @param  string $alias
  * @param  \ReflectionClass $context
  * @return string
  * @throws Exception\NamespaceNotFoundException
  */
 static function getClass($alias, \ReflectionClass $context)
 {
     if (!strlen($alias)) {
         return $alias;
     }
     if (strncmp($alias, '\\', 1) === 0) {
         return substr($alias, 1);
     }
     $file = $context->getFileName();
     if (!isset(self::$map[$file])) {
         if (self::$cache === NULL) {
             $list = Parser::parse($file);
         } else {
             $key = self::C_FILE . $file;
             $list = self::$cache->load($key);
             if ($list === NULL) {
                 $list = self::$cache->save($key, Parser::parse($file), array(NCache::FILES => array($file)));
             }
         }
         self::$map[$file] = $list;
     }
     $namespace = $context->getNamespaceName();
     if (!isset(self::$map[$file][$namespace])) {
         throw new Exception\NamespaceNotFoundException("Namespace '{$namespace}' not found in '{$file}'.");
     }
     $parts = explode('\\', $alias);
     $first = array_shift($parts);
     if (!isset(self::$map[$file][$namespace][$first])) {
         return ltrim(trim($namespace, '\\') . '\\', '\\') . $alias;
     }
     $appendix = implode('\\', $parts);
     return self::$map[$file][$namespace][$first] . (strlen($appendix) ? '\\' . $appendix : '');
 }
开发者ID:uestla,项目名称:aliaser,代码行数:39,代码来源:Container.php

示例2: actionDefault

 public function actionDefault()
 {
     $cache = new Cache($this->context->cacheStorage, 'Homepage');
     $counts = $cache->load('homepagecounts');
     if ($counts === NULL) {
         $subjectsCount = $this->context->createServicePlaces()->fetchVisible()->count();
         $eventsCount = $this->context->createServiceTimes()->fetchPublic()->group('event_time.event_id')->count();
         $categoriesCount = $this->context->createServiceCategories()->where('subject', '1')->count();
         $counts = array('sc' => $subjectsCount, 'ec' => $eventsCount, 'cc' => $categoriesCount);
         $cache->save('homepagecounts', $counts, array(Cache::EXPIRE => '1 hour', Cache::SLIDING => true, Cache::TAGS => array('event', 'events', 'places', 'place')));
     }
     $this->template->subjectsCount = $counts['sc'];
     $this->template->eventsCount = $counts['ec'];
     $this->template->categoriesCount = $counts['cc'];
     $def = $cache->load('homepagecities');
     if ($def === NULL) {
         $res = Model\Subjects::fetchLocalitiesToCities();
         $cnt = 0;
         foreach ($res as $r) {
             $cnt = $cnt + $r['cnt'];
         }
         $def = array($res, $cnt);
         $cache->save('homepagecities', $def, array('expire' => 100000, 'tags' => 'cities'));
     }
     $this->template->cities = $def[0];
     $this->template->citiesCount = $def[1];
     $this->template->circles = $this->context->createServiceCircles()->order('shift')->where('visible', 1)->limit(4);
 }
开发者ID:soundake,项目名称:pd,代码行数:28,代码来源:HomepagePresenter.php

示例3: getClassMetadata

	/**
	 * @param string
	 * @return ClassMetadata
	 * @throws \Nette\InvalidStateException
	 */
	public function getClassMetadata($class)
	{
		$lower = strtolower($class);

		if (isset($this->metas[$lower])) {
			return $this->metas[$lower];
		}

		if ($this->cache && $this->cache[$lower]) {
			return $this->metas[$lower] = $this->cache[$lower];
		}

		if (!class_exists($lower)) {
			throw new \Nette\InvalidArgumentException("Class '$class' not exist");
		}

		$metadata = new ClassMetadata($class);
		foreach ($this->parsers as $parser) {
			$parser->parse($metadata);
		}

		if ($this->cache) {
			$this->cache->save($lower, $metadata, array(
				Cache::FILES => array($metadata->getReflection()->getFileName())
			));
		}

		return $this->metas[$lower] = $metadata;
	}
开发者ID:norbe,项目名称:framework,代码行数:34,代码来源:ClassMetadataFactory.php

示例4: link

 /**
  * @param string $name
  * @return string
  */
 public function link($name)
 {
     $path = $this->cache->load([$name, $this->debugMode]);
     $files = $this->files[$name];
     $files = is_string($files) ? [$files] : $files;
     if ($path === NULL) {
         $unpackedFiles = $this->unpack($name, $files);
         $time = $this->getModifyTime($unpackedFiles);
         $path = $this->genDir . '/' . $this->getOutputFilename($name, $unpackedFiles, $time, $this->debugMode);
         $this->cache->save([$name, $this->debugMode], $path);
     }
     $genFile = "{$this->wwwDir}/{$path}";
     if (!file_exists($genFile) || $this->debugMode && filemtime($genFile) < (isset($time) ? $time : ($time = $this->getModifyTime($this->unpack($name, $files))))) {
         $start = microtime(TRUE);
         $parsedFiles = $this->compile($this->unpack($name, $files), $genFile);
         if ($this->debugMode) {
             $this->statistics[$name]['time'] = microtime(TRUE) - $start;
             $this->statistics[$name]['parsedFiles'] = $parsedFiles;
         }
     }
     if ($this->debugMode) {
         $unpackedFiles = $this->unpack($name, $files);
         $this->statistics[$name]['size'] = filesize($genFile);
         $this->statistics[$name]['file'] = count($unpackedFiles) > 1 ? $unpackedFiles : reset($unpackedFiles);
         $this->statistics[$name]['date'] = isset($time) ? $time : ($time = $this->getModifyTime($unpackedFiles));
         $this->statistics[$name]['path'] = $path;
     }
     return $path;
 }
开发者ID:sw2eu,项目名称:load-common,代码行数:33,代码来源:BaseCompiler.php

示例5: saveInLatLngCache

 private function saveInLatLngCache(array $stop, $stopId)
 {
     $key = $this->getLatLngCacheKey($stop);
     if (is_string($key)) {
         $this->latLngCache->save($key, $stopId);
     }
 }
开发者ID:bileto,项目名称:gtfs-merger,代码行数:7,代码来源:Stops.php

示例6: import

 public function import()
 {
     $projects = $this->projectEntity->fetchPairs("name", null);
     $statusNewRow = $this->lstErrorStatus->findOneBy(array("status" => "New"));
     foreach ($projects as $projectName => $index) {
         $fileList = $this->dataSource->getFileList("{$projectName}/exception");
         foreach ($fileList as $file) {
             if (pathinfo($file->name, PATHINFO_EXTENSION) != "html") {
                 continue;
             }
             $errorRow = $this->errorEntity->findOneBy(array("source_file" => $file->name));
             if (!$errorRow) {
                 try {
                     $errorFileContent = $this->dataSource->getFileContent($file->name);
                     $archiveFilePath = $this->dataSource->moveToArchive($file->name);
                     $this->exceptionParser->parse($errorFileContent);
                     $errorMessage = $this->exceptionParser->getMessage();
                     $title = $this->exceptionParser->getTitle();
                     $errorRow = $this->errorEntity->insert(array("project_id" => $projects[$projectName]->id, "error_status_id" => $statusNewRow->id, "title" => $title, "message" => $this->exceptionParser->getMessage(), "source_file" => $this->exceptionParser->getSourceFile(), "remote_file" => $archiveFilePath, "error_dt" => $file->lastModified, "ins_process_id" => __METHOD__));
                     $link = "http://" . $_SERVER["HTTP_HOST"] . "/error-list/display/" . $errorRow->id;
                     $this->hipChat->sendMessage("<b>{$projectName}</b> - {$title} - {$errorMessage} <a href=\"{$link}\">Show!</a>");
                 } catch (InvalidArgumentException $e) {
                     // file does not exists in source, how it can happen? That's the question, he?
                 }
             }
         }
     }
     $this->cache->save("lastUpdate", new \DateTime());
 }
开发者ID:RiKap,项目名称:ErrorMonitoring,代码行数:29,代码来源:ImportService.php

示例7: compile

 /**
  * @param Translator $translator
  * @param MessageCatalogueInterface[] $availableCatalogues
  * @param string $locale
  * @throws InvalidArgumentException
  * @return MessageCatalogueInterface|NULL
  */
 public function compile(Translator $translator, array &$availableCatalogues, $locale)
 {
     if (empty($locale)) {
         throw new InvalidArgumentException("Invalid locale.");
     }
     if (isset($availableCatalogues[$locale])) {
         return $availableCatalogues;
     }
     $cacheKey = array($locale, $translator->getFallbackLocales());
     $storage = $this->cache->getStorage();
     if (!$storage instanceof Kdyby\Translation\Caching\PhpFileStorage) {
         if (($messages = $this->cache->load($cacheKey)) !== NULL) {
             $availableCatalogues[$locale] = new MessageCatalogue($locale, $messages);
             return $availableCatalogues;
         }
         $this->catalogueFactory->createCatalogue($translator, $availableCatalogues, $locale);
         $this->cache->save($cacheKey, $availableCatalogues[$locale]->all());
         return $availableCatalogues;
     }
     $storage->hint = $locale;
     $cached = $compiled = $this->cache->load($cacheKey);
     if ($compiled === NULL) {
         $this->catalogueFactory->createCatalogue($translator, $availableCatalogues, $locale);
         $this->cache->save($cacheKey, $compiled = $this->compilePhpCache($translator, $availableCatalogues, $locale));
         $cached = $this->cache->load($cacheKey);
     }
     $availableCatalogues[$locale] = self::load($cached['file']);
     return $availableCatalogues;
 }
开发者ID:tomasstrejcek,项目名称:Translation,代码行数:36,代码来源:CatalogueCompiler.php

示例8: end

 /**
  * Stops and saves the cache.
  * @param  array  dependencies
  * @return void
  */
 public function end(array $dependencies = NULL)
 {
     if ($this->cache === NULL) {
         throw new Nette\InvalidStateException('Output cache has already been saved.');
     }
     $this->cache->save($this->key, ob_get_flush(), (array) $dependencies + (array) $this->dependencies);
     $this->cache = NULL;
 }
开发者ID:jave007,项目名称:test,代码行数:13,代码来源:OutputHelper.php

示例9: isAllowed

 /**
  * {@inheritdoc}
  */
 public function isAllowed($role, $resource, $privilege)
 {
     if (NULL === ($allowed = $this->cache->load([$role, $resource, $privilege]))) {
         $allowed = $this->cache->save([$role, $resource, $privilege], function () use($role, $resource, $privilege) {
             return $this->authorizator->isAllowed($role, $resource, $privilege);
         }, [Cache::TAGS => ['role/' . serialize($role), 'resource/' . serialize($resource), 'privilege/' . serialize($privilege)]]);
     }
     return $allowed;
 }
开发者ID:ark8,项目名称:security,代码行数:12,代码来源:CachingAuthorizator.php

示例10: createMenu

 /**
  * @return mixed
  */
 public function createMenu()
 {
     $neon = $this->cache->load('menu');
     if ($neon === NULL) {
         $neon = Neon::decode(file_get_contents($this->filename));
         $this->cache->save('menu', $neon, array(Cache::FILES => $this->filename));
     }
     return $neon;
 }
开发者ID:ondrs,项目名称:nette-bootstrap,代码行数:12,代码来源:MenuGenerator.php

示例11: storeValue

 /**
  * Save data into cache
  *
  * @param string $key
  * @param mixed $callback
  * @param array|NULL $params
  * @return mixed|NULL
  */
 public function storeValue($key, $callback, array $params = NULL)
 {
     // load from cache
     $savedData = $this->cache->load($key);
     if (!empty($savedData)) {
         return $savedData;
     }
     return $this->cache->save($key, $callback, $params);
 }
开发者ID:pecinaon,项目名称:sandbox,代码行数:17,代码来源:CacheManager.php

示例12: createCached

 /**
  * Create cached route list
  * @param null $module
  * @return ResourceRouteList
  */
 private function createCached($module = NULL)
 {
     $files = array();
     $presenterFiles = Finder::findFiles('*Presenter.php')->from($this->presentersRoot);
     foreach ($presenterFiles as $path => $splFile) {
         $files[] = $path;
     }
     $routeList = $this->routeListFactory->create($module);
     $this->cache->save(self::CACHE_NAME, $routeList, array(Cache::FILES => $files));
     return $routeList;
 }
开发者ID:lucien144,项目名称:Restful,代码行数:16,代码来源:CachedRouteListFactory.php

示例13: save

 public function save($key, $data, array $options = [])
 {
     $netteOptions = [];
     foreach ($options as $type => $option) {
         if (!isset($this->options[$type])) {
             throw new \Exception("Unsupported cache option " . $type . "!");
         }
         $netteOptions[$this->options[$type]] = $option;
     }
     $this->netteCache->save($key, $data, $netteOptions);
 }
开发者ID:bauer01,项目名称:unimapper-nette,代码行数:11,代码来源:Cache.php

示例14: __construct

 public function __construct(\Nette\Database\Context $database, \Nette\DI\Container $context)
 {
     $this->database = $database;
     $this->cache = new \Nette\Caching\Cache($context->getService('cacheStorage'), "system");
     $roles = $this->cache->load("PermissionsRoles");
     $resources = $this->cache->load("PermissionsResources");
     $this->init($roles, $resources);
     if ($roles === NULL || $resources === NULL) {
         $this->cache->save("PermissionsRoles", $this->getRoles());
         $this->cache->save("PermissionsResources", $this->getResources());
     }
 }
开发者ID:GreenOceanCZ,项目名称:kelio-test,代码行数:12,代码来源:PermissionManager.php

示例15: install

 public function install()
 {
     /** @var $package \movi\Packages\Package */
     foreach (array_values($this->manager->getPackages()) as $package) {
         $hash = sha1(Json::encode($package));
         // Load cache
         if ($this->cache->load($package->name) === NULL || $this->cache->load($package->name) !== $hash) {
             $this->installPackage($package);
             $this->cache->save($package->name, $hash);
         }
     }
 }
开发者ID:peterzadori,项目名称:movi,代码行数:12,代码来源:Installer.php


注:本文中的Nette\Caching\Cache::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。