Clear cache in WP Rocket when post permalink (slug) changes

To learn more about the issue:


// Fires before an existing post is updated in the database.
add_action( 'pre_post_update', function( $post_ID, $data ) {    
    // Compare slug, if changed clear cache.
    if ( get_post_field( 'post_name', $post_ID ) != $data['post_name'] ) {
        rocket_clean_files( get_the_permalink( $post_ID ) );
}, 10, 2 );

Using rocket_clean_files instead of rocket_clean_post because when rocket_clean_post is used the updated post does not get preloaded (bug, maybe?).