| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace AATXT\App\Infrastructure\Cache; |
| 6 |
|
| 7 |
/** |
| 8 |
* Cache implementation backed by the WordPress Transients API. |
| 9 |
*/ |
| 10 |
class WordPressTransientCache implements CacheInterface |
| 11 |
{ |
| 12 |
public function get(string $key) |
| 13 |
{ |
| 14 |
$value = get_transient($key); |
| 15 |
return $value === false ? null : $value; |
| 16 |
} |
| 17 |
|
| 18 |
public function set(string $key, $value, int $ttl): void |
| 19 |
{ |
| 20 |
set_transient($key, $value, $ttl); |
| 21 |
} |
| 22 |
|
| 23 |
public function delete(string $key): void |
| 24 |
{ |
| 25 |
delete_transient($key); |
| 26 |
} |
| 27 |
} |
| 28 |
|