get_cache example

public function parse_url_details( $request ) {
        $url = untrailingslashit( $request['url'] );

        if ( empty( $url ) ) {
            return new WP_Error( 'rest_invalid_url', __( 'Invalid URL' ), array( 'status' => 404 ) );
        }

        // Transient per URL.         $cache_key = $this->build_cache_key_for_url( $url );

        // Attempt to retrieve cached response.         $cached_response = $this->get_cache( $cache_key );

        if ( ! empty( $cached_response ) ) {
            $remote_url_response = $cached_response;
        } else {
            $remote_url_response = $this->get_remote_url( $url );

            // Exit if we don't have a valid body or it's empty.             if ( is_wp_error( $remote_url_response ) || empty( $remote_url_response ) ) {
                return $remote_url_response;
            }

            
Home | Imprint | This part of the site doesn't use cookies.