using System.Collections.Concurrent; namespace Jellyfin.Plugin.YandexMusic.Providers; /// /// Normalized genres resolved by the song provider, applied after Jellyfin's metadata merge /// so raw tag ids (rusrap, pop, ...) do not stick to the item. /// public static class GenreCache { private static readonly ConcurrentDictionary Cache = new(StringComparer.Ordinal); /// Stores genres for an audio file path. public static void Set(string? path, string[] genres) { if (string.IsNullOrWhiteSpace(path) || genres.Length == 0) { return; } Cache[path] = genres; } /// Gets genres for an audio file path. public static bool TryGet(string? path, out string[] genres) { if (!string.IsNullOrWhiteSpace(path) && Cache.TryGetValue(path, out var value)) { genres = value; return true; } genres = []; return false; } }