How to cache the results of a query and display the cached results

A More Efficient Count

When querying for a count without interest in the actual content of a post, WordPress provides a found_posts property on the query containing the total number of matches – so you needn’t load every post from the database; you can query for a single post and still retrieve the total count. You can also specify the fields parameter to only return post IDs. Both measures can mitigate a lot of overhead in various scenarios – though it’s worth noting that the latter will disable WordPress’s internal object caching functionality for the query by default.

I’m not familiar with the types_child_post() function or it’s capabilities, but leveraging WordPress core the above would look as such:

/**
 * Queries the database for the number of album-type posts associated with a
 * release-type post.
 * 
 * @param int $release_id The post ID of a release-type post.
 * @return int The number of albums associated with the release.
 */
function count_album_versions( $release_id ) {
  $album_versions_query = new WP_Query(
    [
      'posts_per_page' => 1,
      'post_type'      => 'album',
      'meta_query'     => [
        [
          'key'   => '_wpcf_belongs_release_id',
          'value' => $release_id,
        ],
      ],
    ]
  );

  return $album_versions_query->found_posts;
}

Within your template your count display code would be simplified to:

<?php foreach ($album_posts as $child_post)  { ?>    
    <div class="col py-1">
        <?php include get_template_directory() . '/includes/containers/artist-page-container.php' ;?>
        <?php
          $count = count_album_versions( $child_post->ID );

          if ( $count == 1 ){
            echo "$count version";
          } else {
            echo "$count versions";
          }
        ?>
    </div>
<?php } ?>

Breaking Down a Costly Operation

The above alone may be able to achieve your desired performance threshold, but to answer the question more directly, while you could periodically run a task to perform a costly operation and cache the result in a transient or post meta-data (either via WP-Cron or a cronjob), an even more efficient approach in some situations is to just maintain the value whenever it changes. In this case, that would mean storing the number of versions an album has in post meta on the release post, then updating it whenever a version is added or removed.

Ideally you’d prime the cached values for all relevant posts beforehand, but for convenience and redundancy you can also just perform the costly operation as-necessary – when something tries to retrieve or update the cached value and it’s missing.

/**
 * Retrieves the number of albums associated with a release from a release's
 * post meta-data. Calls on count_album_versions() to query the database
 * and set the count on the release's post meta-data if it is missing.
 *
 * @param int $release_id The post ID of a release-type post.
 * @return int The number of album-type posts associated with the release.
 */
function get_album_version_count( $release_id ) {
  $count = get_post_meta( $release_id, 'album_version_count', true );

  // If the count in post-meta is 0 or otherwise a set value, return it.
  if( $count === 0 || !empty( $count ) )
    return $count;

  // Otherwise, query the database to retrieve the count and update post-meta.
  $count = count_album_versions( $release_id );
  update_post_meta( $release_id, 'album_version_count', $count );

  return $count;
}

/**
 * Modify the album count stored in a release-type post's meta-data by a relative
 * value.
 * 
 * @param int $release_id The post ID of a release-type post.
 * @param int $increment Optional. The value to change the count by. Default 1.
 * @return bool True on success, false on failure or no change to the value.
 */
function increment_album_version_count( $release_id, $increment = 1 ) {
  // Retrieve the current count from post-meta (/run the query to calc it).
  $count = get_album_version_count( $release_id );

  // Update the value in post-meta by the specified amount.
  return update_post_meta( $release_id, 'album_version_count', $count + $increment );
}

/**
 * Handles updating release-type posts' associated album counts when an album-type post changes post status.
 *
 * @param $new_status string The new status of the transitioning post.
 * @param $old_status string The previous status of the transitioning post.
 * @param WP_Post The WP_Post object for the transitioning post.
 */
function update_album_version_count( $new_status, $old_status, $post ) {
  // If the hook fired for a non-album-type post or the status of the post did
  // not change, bail early.
  if( $post->post_type !== 'album' || $new_status === $old_status )
    return;

  $release_id = get_post_meta( $post->ID, '_wpcf_belongs_release_id', true );
  if( empty( $release_id ) ) // Bail if this album is not associated with a release.
    return;

  // If the album transitioned from 'draft' or 'trash' to 'publish', increase
  // the associated release's album count by 1.
  if( $new_status === 'publish' && in_array( $old_status, [ 'draft', 'trash' ] ) )
    increment_album_version_count( $release_id );

  // If the album transitioned from 'publish' to 'draft' or 'trash', decrease
  // the associated release's album count by 1.
  if( $old_status === 'publish' && in_array( $new_status, [ 'draft', 'trash' ] ) )
    increment_album_version_count( $release_id, -1 );
}

add_action( 'transition_post_status', 'update_album_version_count', 10, 3 );

I’ve made some assumptions above – namely that an album actually exists in another status prior to being published and that it will already have the '_wpcf_belongs_release_id' meta-value attached at the time that the status is updated – but the mechanism can be adapted to other scenarios if that is not the case (perhaps by using a wp_after_insert_post hook, for instance).

All of the above in place, you have a vastly more efficient counting operation and a get_album_version_count() function to retrieve the count which will only execute the counting operation if absolutely necessary. Outside of that, all of the overhead from the counting operation is broken down into tiny amounts of work performed when an album transitions between ‘trash”https://wordpress.stackexchange.com/”draft’ to or from 'publish' status.