Skip to content

Commit a47a3e3

Browse files
author
Igor Chepurnoy
authored
Merge pull request #9 from thiagotalma/patch-1
Test cache before use it
2 parents eb5e0c9 + eaa34f2 commit a47a3e3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

models/RouteModel.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ public function getAppRoutes($module = null)
119119
}
120120

121121
$key = [__METHOD__, $module->getUniqueId()];
122-
$cache = $this->cache;
122+
$result = (($this->cache !== null) ? $this->cache->get($key) : false);
123123

124-
if (($result = $cache->get($key)) === false) {
124+
if ($result === false) {
125125
$result = [];
126126
$this->getRouteRecursive($module, $result);
127-
if ($cache !== null) {
128-
$cache->set($key, $result, $this->cacheDuration, new TagDependency([
127+
if ($this->cache !== null) {
128+
$this->cache->set($key, $result, $this->cacheDuration, new TagDependency([
129129
'tags' => self::CACHE_TAG
130130
]));
131131
}
@@ -280,4 +280,4 @@ protected function getActionRoutes($controller, &$result)
280280
}
281281
Yii::endProfile($token, __METHOD__);
282282
}
283-
}
283+
}

0 commit comments

Comments
 (0)