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


PHP Cache::load方法代码示例

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


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

示例1: getAllTranslations

 /**
  * @return array|mixed
  */
 public function getAllTranslations()
 {
     $cacheKey = static::getTableName() . "_data";
     if (!($translations = Cache::load($cacheKey))) {
         $itemClass = static::getItemClass();
         $translations = [];
         $select = $this->db->select();
         // create base
         $select->from([static::getTableName()]);
         if ($this->onCreateQueryCallback) {
             $closure = $this->onCreateQueryCallback;
             $closure($select);
         }
         $translationsData = $this->db->fetchAll($select);
         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, ["translator", "translate"], 999);
     }
     return $translations;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:34,代码来源:Dao.php

示例2: start

 /**
  * @return bool
  */
 public function start()
 {
     if (\Pimcore\Tool::isFrontentRequestByAdmin() && !$this->force) {
         return false;
     }
     if ($content = CacheManager::load($this->key)) {
         echo $content;
         return true;
     }
     $this->captureEnabled = true;
     ob_start();
     return false;
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:16,代码来源:Cache.php

示例3: __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

示例4: 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 = array();
             $cacheTags = array("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:sfie,项目名称:pimcore,代码行数:54,代码来源:Config.php

示例5: 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

示例6: 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 = array();
             $data = $this->db->fetchAll("SHOW COLUMNS FROM " . $table);
             foreach ($data as $d) {
                 $columns[] = $d["Field"];
             }
             Cache::save($columns, $cacheKey, array("system", "resource"), null, 997);
         }
         \Zend_Registry::set($cacheKey, $columns);
     }
     return $columns;
 }
开发者ID:sfie,项目名称:pimcore,代码行数:24,代码来源:AbstractDao.php

示例7: 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

示例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: _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

示例10: getProperties

 /**
  * @return Property[]
  */
 public function getProperties()
 {
     if ($this->o_properties === null) {
         // try to get from cache
         $cacheKey = "object_properties_" . $this->getId();
         $properties = Cache::load($cacheKey);
         if (!is_array($properties)) {
             $properties = $this->getDao()->getProperties();
             $elementCacheTag = $this->getCacheTag();
             $cacheTags = ["object_properties" => "object_properties", $elementCacheTag => $elementCacheTag];
             Cache::save($properties, $cacheKey, $cacheTags);
         }
         $this->setProperties($properties);
     }
     return $this->o_properties;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:19,代码来源:AbstractObject.php

示例11: inc

 /**
  * includes a document
  *
  * @param $include
  * @param array $params
  * @return string
  */
 public function inc($include, $params = null, $cacheEnabled = true)
 {
     if (!is_array($params)) {
         $params = [];
     }
     // check if output-cache is enabled, if so, we're also using the cache here
     $cacheKey = null;
     $cacheConfig = false;
     if ($cacheEnabled) {
         if ($cacheConfig = Tool\Frontend::isOutputCacheEnabled()) {
             // cleanup params to avoid serializing Element\ElementInterface objects
             $cacheParams = $params;
             $cacheParams["~~include-document"] = $include;
             array_walk($cacheParams, function (&$value, $key) {
                 if ($value instanceof Element\ElementInterface) {
                     $value = $value->getId();
                 } elseif (is_object($value) && method_exists($value, "__toString")) {
                     $value = (string) $value;
                 }
             });
             $cacheKey = "tag_inc__" . md5(serialize($cacheParams));
             if ($content = Cache::load($cacheKey)) {
                 return $content;
             }
         }
     }
     $editmodeBackup = \Zend_Registry::get("pimcore_editmode");
     \Zend_Registry::set("pimcore_editmode", false);
     $includeBak = $include;
     // this is if $this->inc is called eg. with $this->href() as argument
     if (!$include instanceof Model\Document\PageSnippet && is_object($include) && method_exists($include, "__toString")) {
         $include = (string) $include;
     }
     if (is_string($include)) {
         try {
             $include = Model\Document::getByPath($include);
         } catch (\Exception $e) {
             $include = $includeBak;
         }
     } elseif (is_numeric($include)) {
         try {
             $include = Model\Document::getById($include);
         } catch (\Exception $e) {
             $include = $includeBak;
         }
     }
     $params = array_merge($params, array("document" => $include));
     $content = "";
     if ($include instanceof Model\Document\PageSnippet && $include->isPublished()) {
         if ($include->getAction() && $include->getController()) {
             $content = $this->action($include->getAction(), $include->getController(), $include->getModule(), $params);
         } elseif ($include->getTemplate()) {
             $content = $this->action("default", "default", null, $params);
         }
         // in editmode, we need to parse the returned html from the document include
         // add a class and the pimcore id / type so that it can be opened in editmode using the context menu
         // if there's no first level HTML container => add one (wrapper)
         if ($this->editmode) {
             include_once "simple_html_dom.php";
             $editmodeClass = " pimcore_editable pimcore_tag_inc ";
             // this is if the content that is included does already contain markup/html
             // this is needed by the editmode to highlight included documents
             if ($html = str_get_html($content)) {
                 $childs = $html->find("*");
                 if (is_array($childs)) {
                     foreach ($childs as $child) {
                         $child->class = $child->class . $editmodeClass;
                         $child->pimcore_type = $include->getType();
                         $child->pimcore_id = $include->getId();
                     }
                 }
                 $content = $html->save();
                 $html->clear();
                 unset($html);
             } else {
                 // add a div container if the include doesn't contain markup/html
                 $content = '<div class="' . $editmodeClass . '" pimcore_id="' . $include->getId() . '" pimcore_type="' . $include->getType() . '">' . $content . '</div>';
             }
         }
         // we need to add a component id to all first level html containers
         $componentId = "";
         if ($this->document instanceof Model\Document) {
             $componentId .= 'document:' . $this->document->getId() . '.';
         }
         $componentId .= 'type:inc.name:' . $include->getId();
         $content = \Pimcore\Tool\Frontend::addComponentIdToHtml($content, $componentId);
     }
     \Zend_Registry::set("pimcore_editmode", $editmodeBackup);
     // write contents to the cache, if output-cache is enabled
     if ($cacheConfig) {
         Cache::save($content, $cacheKey, array("output", "output_inline"), $cacheConfig["lifetime"]);
     }
     return $content;
//.........这里部分代码省略.........
开发者ID:jjpeters67,项目名称:pimcore,代码行数:101,代码来源:View.php

示例12: getConfig

 /**
  * @return \Zend_Config
  */
 protected function getConfig()
 {
     if ($this->config) {
         return $this->config;
     }
     $config = Cache::load(self::CONFIG_CACHE_KEY);
     if (!$config) {
         $config = new \Zend_Config_Xml((string) new FileLocator(self::CONFIG_FILE), null, true);
         Cache::save($config, self::CONFIG_CACHE_KEY);
     }
     $this->config = $config;
     return $this->config;
 }
开发者ID:diePartments,项目名称:pimcore-dependency-injection-plugin,代码行数:16,代码来源:Plugin.php

示例13: 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

示例14: getProperties

 /**
  * Get a list of properties (including the inherited)
  *
  * @return Property[]
  */
 public function getProperties()
 {
     if ($this->properties === null) {
         // try to get from cache
         $cacheKey = "document_properties_" . $this->getId();
         $properties = \Pimcore\Cache::load($cacheKey);
         if (!is_array($properties)) {
             $properties = $this->getDao()->getProperties();
             $elementCacheTag = $this->getCacheTag();
             $cacheTags = array("document_properties" => "document_properties", $elementCacheTag => $elementCacheTag);
             \Pimcore\Cache::save($properties, $cacheKey, $cacheTags);
         }
         $this->setProperties($properties);
     }
     return $this->properties;
 }
开发者ID:elavarasann,项目名称:pimcore,代码行数:21,代码来源:Document.php

示例15: 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


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