コード例 #1
0
ファイル: Template.php プロジェクト: romeoz/rock-template
 /**
  * Caching template.
  *
  * @param string $key
  * @param mixed $value
  * @param int $expire
  * @param array $tags
  */
 protected function setCacheContent($key = null, $value = null, $expire = 0, array $tags = [])
 {
     if ($this->cache instanceof CacheInterface && isset($key)) {
         if (!empty($this->cachePlaceholders)) {
             $result = $value;
             $value = [];
             $value['result'] = $result;
             $value['placeholders'] = $this->cachePlaceholders;
         }
         $this->cache->set($key, $value, $expire, is_string($tags) ? explode(',', $tags) : $tags);
         $this->cachePlaceholders = [];
     }
 }
コード例 #2
0
ファイル: Route.php プロジェクト: romeoz/rock-route
 /**
  * Returns list prepared rules.
  * @return array
  */
 public function getRawRules()
 {
     if (!empty($this->rawRules)) {
         return $this->rawRules;
     }
     if ($this->enableCache && isset($this->cache)) {
         if (($data = $this->cache->get(static::className())) !== false) {
             list($rawRules, $aliases) = $data;
             Alias::setAliases($this->prepareAliases($aliases), false);
             $rawRules = $this->calculateCacheRules($rawRules, $this->rules);
             return $this->rawRules = $rawRules;
         }
     }
     $rawRules = $aliases = [];
     $this->normalizeRules($rawRules, $aliases, $this->rules);
     if ($this->enableCache && isset($this->cache)) {
         $this->cache->set(static::className(), [$this->normalizeCacheRules($rawRules), $aliases]);
     }
     return $this->rawRules = $rawRules;
 }