That... Could have gone better
This commit is contained in:
parent
605e204453
commit
c62df9d631
11 changed files with 32 additions and 39 deletions
|
|
@ -24,6 +24,11 @@ class JSONCache {
|
|||
return false;
|
||||
}
|
||||
|
||||
public function exists(string $cache_key): bool {
|
||||
$filename = $this->cache_path . '/' . $cache_key . '.json';
|
||||
return is_file($filename);
|
||||
}
|
||||
|
||||
public function set(string $cache_key, mixed $data, $timeout = 3600) {
|
||||
file_put_contents($this->cache_path . '/' . $cache_key . '.json', json_encode([
|
||||
'data' => $data,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,11 @@ class RedisCache {
|
|||
return null;
|
||||
}
|
||||
|
||||
public function set(string $cache_key, array $data, $timeout = 3600) {
|
||||
$this->client->set($cache_key, json_encode($data), $timeout);
|
||||
public function exists(string $cache_key): bool {
|
||||
return $this->client->exists($cache_key);
|
||||
}
|
||||
|
||||
public function set(string $cache_key, string $data, $timeout = 3600) {
|
||||
$this->client->set($cache_key, $data, $timeout);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue