add delete and has method to Cache

This commit is contained in:
David Remer 2020-09-14 07:28:45 +03:00
parent 3803ba935c
commit bc6be4993a

View file

@ -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.
*