Skip to content
This repository has been archived by the owner on Jan 14, 2020. It is now read-only.

Commit

Permalink
Merge pull request #68 from tommysolsen/bugfix/file_content
Browse files Browse the repository at this point in the history
Fix loadPage caching
  • Loading branch information
thomas-alrek authored Aug 7, 2019
2 parents cffb895 + e9983ed commit f643d47
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/Netflex/Site/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,9 @@ public function purge()
* @param $ttl int Cache time to live
* @param $callback function A function that resolves the value if it is not already cached
*/
public static function resolve($key, $ttl = 3600, $callback)
{
if (self::$cache->has($key)) {
return self::$cache->get($key);
public function resolve($key, $ttl = 3600, $callback) {
if ($this->has($key)) {
return $this->get($key);
}

$ttlValue = null;
Expand All @@ -241,8 +240,8 @@ public static function resolve($key, $ttl = 3600, $callback)
$response = $callback();
}

self::$cache->set($key, $response, '_', $ttlValue ?? $ttl);
$this->set($key, $response, '_', $ttlValue ?? $ttl);

return self::$cache->get($key);
return $this->get($key);
}
}
4 changes: 2 additions & 2 deletions src/Netflex/Site/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public function loadGlobals () {
public function loadPage($id, $revision) {
global $_mode;

$this->content = NF::$cache->fetch('page/' . $id);
$this->content = NF::$cache->fetch("page/$id");
if ($_mode || !$this->content) {
$this->loadContent($id, $revision);
NF::$cache->save('page/$id', $this->content);
NF::$cache->save("page/$id", $this->content);
}
}

Expand Down

0 comments on commit f643d47

Please sign in to comment.