From bc6be4993aac8c2396c52cdc93f4f42f48c8f832 Mon Sep 17 00:00:00 2001 From: David Remer Date: Mon, 14 Sep 2020 07:28:45 +0300 Subject: [PATCH] add delete and has method to Cache --- .../src/Helper/class-cache.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/modules/ppcp-api-client/src/Helper/class-cache.php b/modules/ppcp-api-client/src/Helper/class-cache.php index 2af1e5246..503e95739 100644 --- a/modules/ppcp-api-client/src/Helper/class-cache.php +++ b/modules/ppcp-api-client/src/Helper/class-cache.php @@ -41,6 +41,26 @@ class Cache { return get_transient( $this->prefix . $key ); } + /** + * Whether a value is stored or not. + * + * @param string $key The key for the value. + * + * @return bool + */ + public function has( string $key ): bool { + return $this->get( $key ) !== false; + } + + /** + * Deletes a cache. + * + * @param string $key The key. + */ + public function delete( string $key ) { + delete_transient( $this->prefix . $key ); + } + /** * Caches a value. *