wordpress-seo
/
src
/
expiring-store
/
application
/
ports
/
expiring-store-repository-interface.php
expiring-store-repository-interface.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.6, at src/expiring-store/application/ports/expiring-store-repository-interface.php
| 1 | <?php |
| 2 | |
| 3 | // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure. |
| 4 | namespace Yoast\WP\SEO\Expiring_Store\Application\Ports; |
| 5 | |
| 6 | /** |
| 7 | * Port for the expiring store repository. |
| 8 | */ |
| 9 | interface Expiring_Store_Repository_Interface { |
| 10 | |
| 11 | /** |
| 12 | * Inserts or replaces a value in the expiring store. |
| 13 | * |
| 14 | * @param string $key The key to store. |
| 15 | * @param string $json_value The JSON-encoded value. |
| 16 | * @param string $expiration_datetime The expiration datetime in 'Y-m-d H:i:s' format. |
| 17 | * |
| 18 | * @return void |
| 19 | */ |
| 20 | public function upsert( string $key, string $json_value, string $expiration_datetime ): void; |
| 21 | |
| 22 | /** |
| 23 | * Finds a non-expired value by key. |
| 24 | * |
| 25 | * @param string $key The key to find. |
| 26 | * @param string $current_datetime The current datetime in 'Y-m-d H:i:s' format. |
| 27 | * |
| 28 | * @return string|null The JSON-encoded value, or null if not found or expired. |
| 29 | */ |
| 30 | public function find( string $key, string $current_datetime ): ?string; |
| 31 | |
| 32 | /** |
| 33 | * Inserts a value only if the key does not already exist or has expired. |
| 34 | * |
| 35 | * @param string $key The key to store. |
| 36 | * @param string $json_value The JSON-encoded value. |
| 37 | * @param string $expiration_datetime The expiration datetime in 'Y-m-d H:i:s' format. |
| 38 | * @param string $current_datetime The current datetime in 'Y-m-d H:i:s' format. |
| 39 | * |
| 40 | * @return bool True if the value was inserted or an expired row was replaced, false if the key already exists and is not expired. |
| 41 | */ |
| 42 | public function insert_if_absent( string $key, string $json_value, string $expiration_datetime, string $current_datetime ): bool; |
| 43 | |
| 44 | /** |
| 45 | * Deletes a value by key. |
| 46 | * |
| 47 | * @param string $key The key to delete. |
| 48 | * |
| 49 | * @return void |
| 50 | */ |
| 51 | public function delete( string $key ): void; |
| 52 | |
| 53 | /** |
| 54 | * Deletes all expired entries. |
| 55 | * |
| 56 | * @param string $current_datetime The current datetime in 'Y-m-d H:i:s' format. |
| 57 | * |
| 58 | * @return int The number of deleted rows. |
| 59 | */ |
| 60 | public function delete_expired( string $current_datetime ): int; |
| 61 | } |
| 62 |