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


PHP Cache::save方法代码示例

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


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

示例1: dispatchLoopShutdown

 /**
  *
  */
 public function dispatchLoopShutdown()
 {
     $code = (string) $this->getResponse()->getHttpResponseCode();
     if ($code && ($code[0] == "4" || $code[0] == "5")) {
         $this->writeLog();
         // put the response into the cache, this is read in Pimcore_Controller_Action_Frontend::checkForErrors()
         $responseData = $this->getResponse()->getBody();
         if (strlen($responseData) > 20) {
             $cacheKey = "error_page_response_" . \Pimcore\Tool\Frontend::getSiteKey();
             \Pimcore\Cache::save($responseData, $cacheKey, array("output"), 900, 9992);
         }
     }
 }
开发者ID:elavarasann,项目名称:pimcore,代码行数:16,代码来源:HttpErrorLog.php

示例2: __construct

 /**
  * @param $domain
  */
 public function __construct($domain)
 {
     $this->_domain = $domain;
     try {
         $robotsUrl = $domain . '/robots.txt';
         $cacheKey = "robots_" . crc32($robotsUrl);
         if (!($robotsTxt = Cache::load($cacheKey))) {
             $robotsTxt = \Pimcore\Tool::getHttpData($robotsUrl);
             Cache::save($robotsTxt, $cacheKey, array("system"), 3600, 999, true);
         }
         $this->_rules = $this->_makeRules($robotsTxt);
     } catch (\Exception $e) {
     }
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:17,代码来源:RobotsTxt.php

示例3: dispatchLoopShutdown

 /**
  *
  */
 public function dispatchLoopShutdown()
 {
     $code = (string) $this->getResponse()->getHttpResponseCode();
     if ($code && ($code[0] == "4" || $code[0] == "5")) {
         $this->writeLog();
         // put the response into the cache, this is read in Pimcore\Controller\Action\Frontend::checkForErrors()
         $responseData = $this->getResponse()->getBody();
         if (strlen($responseData) > 20 && !session_id()) {
             // do not cache if there's no data or an active session
             if ($this->cacheKey) {
                 \Pimcore\Cache::save($responseData, $this->cacheKey, ["output"], 900, 9992);
             }
         }
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:18,代码来源:HttpErrorLog.php

示例4: load

 /**
  *
  */
 public function load()
 {
     $client = Api::getSimpleClient();
     $config = $this->getConfig();
     $perPage = $this->getPerPage();
     $offset = $this->getOffset();
     $query = $this->getQuery();
     if ($client) {
         $search = new \Google_Service_Customsearch($client);
         // determine language
         $language = "";
         if (\Zend_Registry::isRegistered("Zend_Locale")) {
             $locale = \Zend_Registry::get("Zend_Locale");
             $language = $locale->getLanguage();
         }
         if (!array_key_exists("hl", $config) && !empty($language)) {
             $config["hl"] = $language;
         }
         if (!array_key_exists("lr", $config) && !empty($language)) {
             $config["lr"] = "lang_" . $language;
         }
         if ($query) {
             if ($offset) {
                 $config["start"] = $offset + 1;
             }
             if (empty($perPage)) {
                 $perPage = 10;
             }
             $config["num"] = $perPage;
             $cacheKey = "google_cse_" . md5($query . serialize($config));
             // this is just a protection so that no query get's sent twice in a request (loops, ...)
             if (\Zend_Registry::isRegistered($cacheKey)) {
                 $result = \Zend_Registry::get($cacheKey);
             } else {
                 if (!($result = Cache::load($cacheKey))) {
                     $result = $search->cse->listCse($query, $config);
                     Cache::save($result, $cacheKey, array("google_cse"), 3600, 999);
                     \Zend_Registry::set($cacheKey, $result);
                 }
             }
             $this->readGoogleResponse($result);
             return $this->getResults(false);
         }
         return array();
     } else {
         throw new \Exception("Google Simple API Key is not configured in System-Settings.");
     }
 }
开发者ID:sfie,项目名称:pimcore,代码行数:51,代码来源:Cse.php

示例5: getValidTableColumns

 /**
  * @param string $table
  * @param bool $cache
  * @return array|mixed
  */
 public function getValidTableColumns($table, $cache = true)
 {
     $cacheKey = self::CACHEKEY . $table;
     if (\Zend_Registry::isRegistered($cacheKey)) {
         $columns = \Zend_Registry::get($cacheKey);
     } else {
         $columns = Cache::load($cacheKey);
         if (!$columns || !$cache) {
             $columns = [];
             $data = $this->db->fetchAll("SHOW COLUMNS FROM " . $table);
             foreach ($data as $d) {
                 $columns[] = $d["Field"];
             }
             Cache::save($columns, $cacheKey, ["system", "resource"], null, 997);
         }
         \Zend_Registry::set($cacheKey, $columns);
     }
     return $columns;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:24,代码来源:AbstractDao.php

示例6: frontend

 /**
  * @see Document\Tag\TagInterface::frontend
  * @return string
  */
 public function frontend()
 {
     if ($this->url) {
         $config = $this->getOptions();
         if (!isset($config["params"])) {
             $config["params"] = [];
         }
         foreach (["width", "height"] as $property) {
             if (isset($config[$property])) {
                 $config["params"][$property] = $config[$property];
             }
         }
         $cacheKey = "doc_embed_" . crc32(serialize([$this->url, $config]));
         if (!($html = \Pimcore\Cache::load($cacheKey))) {
             $embera = new \Embera\Embera($config);
             $html = $embera->autoEmbed($this->url);
             \Pimcore\Cache::save($html, $cacheKey, ["embed"], 86400, 1, true);
         }
         return $html;
     }
     return "";
 }
开发者ID:solverat,项目名称:pimcore,代码行数:26,代码来源:Embed.php

示例7: _loadTranslationData

 /**
  * @param null $data
  * @param $locale
  * @param array $options
  * @return array
  */
 protected function _loadTranslationData($data, $locale, array $options = array())
 {
     $locale = (string) $locale;
     $tmpKeyParts = explode("\\", self::getBackend());
     $cacheKey = "Translate_" . array_pop($tmpKeyParts) . "_data_" . $locale;
     if (!($data = Cache::load($cacheKey))) {
         $data = array("__pimcore_dummy" => "only_a_dummy");
         $listClass = self::getBackend() . "\\Listing";
         $list = new $listClass();
         if ($list->isCacheable()) {
             $list->setCondition("language = ?", array($locale));
             $translations = $list->loadRaw();
             foreach ($translations as $translation) {
                 $data[mb_strtolower($translation["key"])] = Tool\Text::removeLineBreaks($translation["text"]);
             }
             Cache::save($data, $cacheKey, array("translator", "translator_website", "translate"), null, 999);
             $this->isCacheable = true;
         } else {
             $this->isCacheable = false;
         }
     }
     $this->_translate[$locale] = $data;
     return $this->_translate;
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:30,代码来源:Translate.php

示例8: getAllTranslations

 /**
  * @return array|mixed
  */
 public function getAllTranslations()
 {
     $cacheKey = static::getTableName() . "_data";
     if (!($translations = Cache::load($cacheKey))) {
         $itemClass = static::getItemClass();
         $translations = array();
         $translationsData = $this->db->fetchAll("SELECT * FROM " . static::getTableName());
         foreach ($translationsData as $t) {
             if (!$translations[$t["key"]]) {
                 $translations[$t["key"]] = new $itemClass();
                 $translations[$t["key"]]->setKey($t["key"]);
             }
             $translations[$t["key"]]->addTranslation($t["language"], $t["text"]);
             //for legacy support
             if ($translations[$t["key"]]->getDate() < $t["creationDate"]) {
                 $translations[$t["key"]]->setDate($t["creationDate"]);
             }
             $translations[$t["key"]]->setCreationDate($t["creationDate"]);
             $translations[$t["key"]]->setModificationDate($t["modificationDate"]);
         }
         Cache::save($translations, $cacheKey, array("translator", "translate"), 999);
     }
     return $translations;
 }
开发者ID:elavarasann,项目名称:pimcore,代码行数:27,代码来源:Dao.php

示例9: getWebsiteConfig

 /**
  * @static
  * @return mixed|\Zend_Config
  */
 public static function getWebsiteConfig()
 {
     if (\Zend_Registry::isRegistered("pimcore_config_website")) {
         $config = \Zend_Registry::get("pimcore_config_website");
     } else {
         $cacheKey = "website_config";
         $siteId = null;
         if (Model\Site::isSiteRequest()) {
             $siteId = Model\Site::getCurrentSite()->getId();
         } elseif (Tool::isFrontentRequestByAdmin()) {
             // this is necessary to set the correct settings in editmode/preview (using the main domain)
             $front = \Zend_Controller_Front::getInstance();
             $originDocument = $front->getRequest()->getParam("document");
             if ($originDocument) {
                 $site = Tool\Frontend::getSiteForDocument($originDocument);
                 if ($site) {
                     $siteId = $site->getId();
                 }
             }
         }
         if ($siteId) {
             $cacheKey = $cacheKey . "_site_" . $siteId;
         }
         if (!($config = Cache::load($cacheKey))) {
             $settingsArray = [];
             $cacheTags = ["website_config", "system", "config", "output"];
             $list = new Model\WebsiteSetting\Listing();
             $list = $list->load();
             foreach ($list as $item) {
                 $key = $item->getName();
                 $itemSiteId = $item->getSiteId();
                 if ($itemSiteId != 0 && $itemSiteId != $siteId) {
                     continue;
                 }
                 $s = null;
                 switch ($item->getType()) {
                     case "document":
                     case "asset":
                     case "object":
                         $s = Model\Element\Service::getElementById($item->getType(), $item->getData());
                         break;
                     case "bool":
                         $s = (bool) $item->getData();
                         break;
                     case "text":
                         $s = (string) $item->getData();
                         break;
                 }
                 if ($s instanceof Model\Element\ElementInterface) {
                     $cacheTags = $s->getCacheTags($cacheTags);
                 }
                 if (isset($s)) {
                     $settingsArray[$key] = $s;
                 }
             }
             $config = new \Zend_Config($settingsArray, true);
             Cache::save($config, $cacheKey, $cacheTags, null, 998);
         }
         self::setWebsiteConfig($config);
     }
     return $config;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:66,代码来源:Config.php

示例10: getWebsiteConfig

 /**
  * @static
  * @return mixed|\Zend_Config
  */
 public static function getWebsiteConfig()
 {
     if (\Zend_Registry::isRegistered("pimcore_config_website")) {
         $config = \Zend_Registry::get("pimcore_config_website");
     } else {
         $cacheKey = "website_config";
         $siteId = null;
         if (Model\Site::isSiteRequest()) {
             $siteId = Model\Site::getCurrentSite()->getId();
             $cacheKey = $cacheKey . "_site_" . $siteId;
         }
         if (!($config = Cache::load($cacheKey))) {
             $settingsArray = [];
             $cacheTags = ["website_config", "system", "config", "output"];
             $list = new Model\WebsiteSetting\Listing();
             $list = $list->load();
             foreach ($list as $item) {
                 $key = $item->getName();
                 $itemSiteId = $item->getSiteId();
                 if ($itemSiteId != 0 && $itemSiteId != $siteId) {
                     continue;
                 }
                 $s = null;
                 switch ($item->getType()) {
                     case "document":
                     case "asset":
                     case "object":
                         $s = Model\Element\Service::getElementById($item->getType(), $item->getData());
                         break;
                     case "bool":
                         $s = (bool) $item->getData();
                         break;
                     case "text":
                         $s = (string) $item->getData();
                         break;
                 }
                 if ($s instanceof Model\Element\ElementInterface) {
                     $cacheTags = $s->getCacheTags($cacheTags);
                 }
                 if (isset($s)) {
                     $settingsArray[$key] = $s;
                 }
             }
             $config = new \Zend_Config($settingsArray, true);
             Cache::save($config, $cacheKey, $cacheTags, null, 998);
         }
         self::setWebsiteConfig($config);
     }
     return $config;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:54,代码来源:Config.php

示例11: end

 /**
  *
  */
 public function end()
 {
     if ($this->captureEnabled) {
         $this->captureEnabled = false;
         $tags = array("in_template");
         if (!$this->lifetime) {
             $tags[] = "output";
         }
         $content = ob_get_clean();
         CacheManager::save($content, $this->key, $tags, $this->lifetime, 996, true);
         echo $content;
     }
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:16,代码来源:Cache.php

示例12: getByDomain

 /**
  * @param $domain
  * @return mixed|Site|string
  * @throws \Exception
  */
 public static function getByDomain($domain)
 {
     // cached because this is called in the route (Pimcore_Controller_Router_Route_Frontend)
     $cacheKey = "site_domain_" . md5($domain);
     if (!($site = \Pimcore\Cache::load($cacheKey))) {
         $site = new self();
         try {
             $site->getDao()->getByDomain($domain);
         } catch (\Exception $e) {
             \Logger::debug($e);
             $site = "failed";
         }
         \Pimcore\Cache::save($site, $cacheKey, ["system", "site"]);
     }
     if ($site == "failed" || !$site) {
         $msg = "there is no site for the requested domain [" . $domain . "], content was [" . $site . "]";
         \Logger::debug($msg);
         throw new \Exception($msg);
     }
     return $site;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:26,代码来源:Site.php

示例13: getText

 public function getText($page = null)
 {
     if (\Pimcore\Document::isAvailable() && \Pimcore\Document::isFileTypeSupported($this->getFilename())) {
         $cacheKey = "asset_document_text_" . $this->getId() . "_" . ($page ? $page : "all");
         if (!($text = Cache::load($cacheKey))) {
             $document = \Pimcore\Document::getInstance();
             $text = $document->getText($page, $this->getFileSystemPath());
             Cache::save($text, $cacheKey, $this->getCacheTags(), null, 99, true);
             // force cache write
         }
         return $text;
     } else {
         Logger::error("Couldn't get text out of document " . $this->getRealFullPath() . " no document adapter is available");
     }
     return null;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:16,代码来源:Document.php

示例14: getSupportedLocales

 /**
  * @return array|mixed
  * @throws \Zend_Locale_Exception
  */
 public static function getSupportedLocales()
 {
     // List of locales that are no longer part of CLDR
     // this was also changed in the Zend Framework, but here we need to provide an appropriate alternative
     // since this information isn't public in \Zend_Locale :-(
     $aliases = ['az_AZ' => true, 'bs_BA' => true, 'ha_GH' => true, 'ha_NE' => true, 'ha_NG' => true, 'kk_KZ' => true, 'ks_IN' => true, 'mn_MN' => true, 'ms_BN' => true, 'ms_MY' => true, 'ms_SG' => true, 'pa_IN' => true, 'pa_PK' => true, 'shi_MA' => true, 'sr_BA' => true, 'sr_ME' => true, 'sr_RS' => true, 'sr_XK' => true, 'tg_TJ' => true, 'tzm_MA' => true, 'uz_AF' => true, 'uz_UZ' => true, 'vai_LR' => true, 'zh_CN' => true, 'zh_HK' => true, 'zh_MO' => true, 'zh_SG' => true, 'zh_TW' => true];
     $locale = \Zend_Locale::findLocale();
     $cacheKey = "system_supported_locales_" . strtolower((string) $locale);
     if (!($languageOptions = Cache::load($cacheKey))) {
         // we use the locale here, because \Zend_Translate only supports locales not "languages"
         $languages = \Zend_Locale::getLocaleList();
         $languages = array_merge($languages, $aliases);
         $languageOptions = array();
         foreach ($languages as $code => $active) {
             if ($active) {
                 $translation = \Zend_Locale::getTranslation($code, "language");
                 if (!$translation) {
                     $tmpLocale = new \Zend_Locale($code);
                     $lt = \Zend_Locale::getTranslation($tmpLocale->getLanguage(), "language");
                     $tt = \Zend_Locale::getTranslation($tmpLocale->getRegion(), "territory");
                     if ($lt && $tt) {
                         $translation = $lt . " (" . $tt . ")";
                     }
                 }
                 if (!$translation) {
                     $translation = $code;
                 }
                 $languageOptions[$code] = $translation;
             }
         }
         asort($languageOptions);
         Cache::save($languageOptions, $cacheKey, ["system"]);
     }
     return $languageOptions;
 }
开发者ID:elavarasann,项目名称:pimcore,代码行数:39,代码来源:Tool.php

示例15: frontend

 /**
  * @see Document\Tag\TagInterface::frontend
  * @return string
  */
 public function frontend()
 {
     if ($this->getView() instanceof \Zend_View) {
         try {
             if ($this->snippet instanceof Document\Snippet) {
                 $params = $this->options;
                 $params["document"] = $this->snippet;
                 if ($this->snippet->isPublished()) {
                     // check if output-cache is enabled, if so, we're also using the cache here
                     $cacheKey = null;
                     if ($cacheConfig = \Pimcore\Tool\Frontend::isOutputCacheEnabled()) {
                         // cleanup params to avoid serializing Element\ElementInterface objects
                         $cacheParams = $params;
                         array_walk($cacheParams, function (&$value, $key) {
                             if ($value instanceof Model\Element\ElementInterface) {
                                 $value = $value->getId();
                             }
                         });
                         $cacheKey = "tag_snippet__" . md5(serialize($cacheParams));
                         if ($content = Cache::load($cacheKey)) {
                             return $content;
                         }
                     }
                     $content = $this->getView()->action($this->snippet->getAction(), $this->snippet->getController(), $this->snippet->getModule(), $params);
                     // write contents to the cache, if output-cache is enabled
                     if ($cacheConfig) {
                         Cache::save($content, $cacheKey, ["output", "output_inline"], $cacheConfig["lifetime"]);
                     }
                     return $content;
                 }
                 return "";
             }
         } catch (\Exception $e) {
             if (\Pimcore::inDebugMode()) {
                 return "ERROR: " . $e->getMessage() . " (for details see debug.log)";
             }
             \Logger::error($e);
         }
     } else {
         return null;
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:46,代码来源:Snippet.php


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