Files
jellyfin-plugin-yandexmusic/Jellyfin.Plugin.YandexMusic/Providers/ArtistCache.cs
T

37 lines
1.0 KiB
C#

using System.Collections.Concurrent;
namespace Jellyfin.Plugin.YandexMusic.Providers;
/// <summary>
/// Artists resolved from Yandex for an audio file. Applied after the merge so stale or
/// combined artist names from tags do not accumulate between refreshes.
/// </summary>
public static class ArtistCache
{
private static readonly ConcurrentDictionary<string, string[]> Cache = new(StringComparer.Ordinal);
/// <summary>Stores artists for an audio file path.</summary>
public static void Set(string? path, string[] artists)
{
if (string.IsNullOrWhiteSpace(path) || artists.Length == 0)
{
return;
}
Cache[path] = artists;
}
/// <summary>Gets artists for an audio file path.</summary>
public static bool TryGet(string? path, out string[] artists)
{
if (!string.IsNullOrWhiteSpace(path) && Cache.TryGetValue(path, out var value))
{
artists = value;
return true;
}
artists = [];
return false;
}
}