expiration_time = apply_filters( 'optml_page_profiler_transient_expiration', self::EXPIRATION_TIME ); } /** * Generates the full transient key with prefix. * * @param string $key The base key to prefix. * @return string The prefixed key. */ private function get_key( string $key ) { return self::PREFIX . $key; } /** * Stores data in a transient. * * @param string $key The key to store the data under. * @param array $data The data to store. * @return void */ public function store( string $key, array $data ) { set_transient( $this->get_key( $key ), $data, $this->expiration_time ); if ( OPTML_DEBUG ) { do_action( 'optml_log', 'stored: ' . $this->get_key( $key ) . '|' . print_r( $data, true ) ); } } /** * Retrieves data from a transient. * * @param string $key The key to retrieve data for. * @return mixed The stored data or false if the transient doesn't exist or has expired. */ public function get( string $key ) { return get_transient( $this->get_key( $key ) ); } /** * Deletes a specific transient. * * @param string $key The key of the transient to delete. * @return void */ public function delete( string $key ) { delete_transient( $this->get_key( $key ) ); } /** * Deletes all transients created by this class. * * @return void * @todo Implement this method to clear all transients with the defined prefix. */ public function delete_all() { // Not implemented for now. } }