| @@ -1,10 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Parsely Remote API Adapter for the WordPress Object Cache | |
| 3 | + * Remote API: Adapter class for the WordPress Object Cache | |
| 4 | 4 | * |
| 5 | 5 | * @package Parsely |
| 6 | - * @since 3.2.0 | |
| 6 | + * @since 3.2.0 | |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | declare(strict_types=1); |
| 10 | 10 | |
| @@ -9,31 +9,14 @@ | ||
| 9 | 9 | declare(strict_types=1); |
| 10 | 10 | |
| 11 | 11 | namespace Parsely\RemoteAPI; |
| 12 | 12 | |
| 13 | -use WP_Object_Cache; | |
| 14 | - | |
| 15 | 13 | /** |
| 16 | 14 | * Remote API Adapter for the WordPress Object Cache. |
| 17 | 15 | */ |
| 18 | 16 | class WordPress_Cache implements Cache { |
| 19 | - /** | |
| 20 | - * The WordPress Object Cache. | |
| 21 | - * | |
| 22 | - * @var WP_Object_Cache | |
| 23 | - */ | |
| 24 | - private $cache; | |
| 25 | 17 | |
| 26 | 18 | /** |
| 27 | - * Constructor. | |
| 28 | - * | |
| 29 | - * @param WP_Object_Cache $cache A class that's compatible with the Cache Interface. | |
| 30 | - */ | |
| 31 | - public function __construct( WP_Object_Cache $cache ) { | |
| 32 | - $this->cache = $cache; | |
| 33 | - } | |
| 34 | - | |
| 35 | - /** | |
| 36 | 19 | * Retrieves the cache contents from the cache by key and group. |
| 37 | 20 | * |
| 38 | 21 | * @since 3.2.0 |
| 39 | 22 | * |
| @@ -45,9 +28,9 @@ | ||
| 45 | 28 | * Disambiguates a return of false, a storable value. Default null. |
| 46 | 29 | * @return mixed|false The cache contents on success, false on failure to retrieve contents. |
| 47 | 30 | */ |
| 48 | 31 | public function get( $key, string $group = '', bool $force = false, bool $found = null ) { |
| 49 | - return $this->cache->get( $key, $group, $force, $found ); | |
| 32 | + return wp_cache_get( $key, $group, $force, $found ); | |
| 50 | 33 | } |
| 51 | 34 | |
| 52 | 35 | /** |
| 53 | 36 | * Saves the data to the cache. |
| @@ -61,8 +44,9 @@ | ||
| 61 | 44 | * @param int $expire Optional. When to expire the cache contents, in seconds. |
| 62 | 45 | * Default 0 (no expiration). |
| 63 | 46 | * @return bool True on success, false on failure. |
| 64 | 47 | */ |
| 65 | - public function set( $key, $data, string $group = '', int $expire = 0 ): bool { | |
| 66 | - return $this->cache->set( $key, $data, $group, $expire ); | |
| 48 | + public function set( $key, $data, string $group = '', $expire = 0 ): bool { | |
| 49 | + // phpcs:ignore WordPressVIPMinimum.Performance.LowExpiryCacheTime.CacheTimeUndetermined | |
| 50 | + return wp_cache_set( $key, $data, $group, $expire ); | |
| 67 | 51 | } |
| 68 | 52 | } |