Skip to content

Commit 34e4385

Browse files
committed
fix: disable cache getter
1 parent c6ebe1c commit 34e4385

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/Cache.php

+7-9
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ protected function __construct()
4040
*/
4141
public function set($key, $value, $ttl = 3600)
4242
{
43-
if (!Scanner::isCacheEnabled()) {
44-
return true;
45-
}
46-
4743
$key = $this->key($key);
4844

4945
if ($data = json_encode(array('ttl' => $ttl > 0 ? time() + $ttl : $ttl, 'data' => $value))) {
46+
if (!Scanner::isCacheEnabled()) {
47+
self::$cache[$key] = $data;
48+
49+
return true;
50+
}
51+
5052
if (file_put_contents($this->tempdir . $key, $data) !== false) {
5153
self::$cache[$key] = $data;
5254

@@ -88,17 +90,13 @@ public function touch($key, $ttl = 3600)
8890
*/
8991
public function get($key, $default = null)
9092
{
91-
if (!Scanner::isCacheEnabled()) {
92-
return $default;
93-
}
94-
9593
$key = $this->key($key);
9694
$file = $this->tempdir . $key;
9795

9896
$data = false;
9997
if (isset(self::$cache[$key])) {
10098
$data = self::$cache[$key];
101-
} elseif (is_file($file)) {
99+
} elseif (Scanner::isCacheEnabled() && is_file($file)) {
102100
$data = file_get_contents($file);
103101
self::$cache[$key] = $data;
104102
}

0 commit comments

Comments
 (0)