| 1 |
<?php |
| 2 |
/** |
| 3 |
* Remote API: Cache interface |
| 4 |
* |
| 5 |
* @package Parsely |
| 6 |
* @since 3.2.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
declare(strict_types=1); |
| 10 |
|
| 11 |
namespace Parsely\RemoteAPI; |
| 12 |
|
| 13 |
/** |
| 14 |
* Remote API Cache Interface |
| 15 |
*/ |
| 16 |
interface Cache { |
| 17 |
/** |
| 18 |
* Retrieves the cache contents from the cache by key and group. |
| 19 |
* |
| 20 |
* @since 3.2.0 |
| 21 |
* |
| 22 |
* @param int|string $key The key under which the cache contents are stored. |
| 23 |
* @param string $group Optional. Where the cache contents are grouped. Default empty. |
| 24 |
* @param bool $force Optional. Whether to force an update of the local cache |
| 25 |
* from the persistent cache. Default false. |
| 26 |
* @param bool $found Optional. Whether the key was found in the cache (passed by reference). |
| 27 |
* Disambiguates a return of false, a storable value. Default null. |
| 28 |
* @return mixed|false The cache contents on success, false on failure to retrieve contents. |
| 29 |
*/ |
| 30 |
public function get( $key, string $group = '', bool $force = false, bool $found = null ); |
| 31 |
|
| 32 |
/** |
| 33 |
* Saves the data to the cache. |
| 34 |
* |
| 35 |
* @since 3.2.0 |
| 36 |
* |
| 37 |
* @param int|string $key The cache key to use for retrieval later. |
| 38 |
* @param mixed $data The contents to store in the cache. |
| 39 |
* @param string $group Optional. Where to group the cache contents. Enables the same key |
| 40 |
* to be used across groups. Default empty. |
| 41 |
* @param int $expire Optional. When to expire the cache contents, in seconds. |
| 42 |
* Default 0 (no expiration). |
| 43 |
* @return bool True on success, false on failure. |
| 44 |
*/ |
| 45 |
public function set( $key, $data, string $group = '', int $expire = 0 ): bool; |
| 46 |
} |
| 47 |
|