code: @SuppressWarnings({"SameParameterValue", "WeakerAccess"})
      public static void createMetadataCache(final SlotReference slot, final int playlistId,
                                      final File cache, final MetadataCacheCreationListener listener)
              throws Exception {
          ConnectionManager.ClientTask<Object> task = new ConnectionManager.ClientTask<Object>() {
              @SuppressWarnings("SameReturnValue")
              @Override
              public Object useClient(Client client) throws Exception {
                  final List<Message> trackList;
                  if (playlistId == 0) {
                      trackList = MetadataFinder.getInstance().getFullTrackList(slot.slot, client, 0);
                  } else {
                      trackList = MetadataFinder.getInstance().getPlaylistItems(slot.slot, 0, playlistId, false, client);
                  }
                  MetadataCache.copyTracksToCache(trackList, playlistId, client, slot, cache, listener);
                  return null;
              }
          };
  
          if (cache.exists() && !cache.delete()) {
              logger.warn("Unable to delete cache file, {}", cache);
          }
          ConnectionManager.getInstance().invokeWithClientSession(slot.player, task, "building metadata cache");
      }
docs: Creates a metadata cache archive file of all tracks in the specified slot on the specified player. Any
  previous contents of the specified file will be replaced. If a non-{@code null} {@code listener} is
  supplied, its {@link MetadataCacheCreationListener#cacheCreationContinuing(TrackMetadata, int, int)} method
  will be called after each track is added to the cache, allowing it to display progress updates to the user,
  and to continue or cancel the process by returning {@code true} or {@code false}.
  
  Because this takes a huge amount of time relative to CDJ status updates, it can only be performed while
  the MetadataFinder is in passive mode.
  
  @param slot the slot in which the media to be cached can be found
  @param playlistId the id of playlist to be cached, or 0 of all tracks should be cached
  @param cache the file into which the metadata cache should be written
  @param listener will be informed after each track is added to the cache file being created and offered
  the opportunity to cancel the process
  
  @throws Exception if there is a problem communicating with the player or writing the cache file