Enhanced cache clearing to include all Spotify playlist Redis keys

- Added clearing of spotify:matched:* and spotify:matched:ordered:* keys
- This ensures bitrate metadata fix takes effect after cache clear
- Returns count of cleared Redis keys in response
This commit is contained in:
2026-02-03 19:41:16 -05:00
parent 64ac09becf
commit 6ab314f603

View File

@@ -838,6 +838,7 @@ public class AdminController : ControllerBase
_logger.LogInformation("Cache clear requested from admin UI"); _logger.LogInformation("Cache clear requested from admin UI");
var clearedFiles = 0; var clearedFiles = 0;
var clearedRedisKeys = 0;
// Clear file cache // Clear file cache
if (Directory.Exists(CacheDirectory)) if (Directory.Exists(CacheDirectory))
@@ -856,14 +857,35 @@ public class AdminController : ControllerBase
} }
} }
// Clear Redis cache for spotify playlists // Clear ALL Redis cache keys for Spotify playlists
// This includes matched tracks, ordered tracks, missing tracks, etc.
foreach (var playlist in _spotifyImportSettings.Playlists) foreach (var playlist in _spotifyImportSettings.Playlists)
{ {
await _cache.DeleteAsync($"spotify:playlist:{playlist.Name}"); var keysToDelete = new[]
await _cache.DeleteAsync($"spotify:missing:{playlist.Name}"); {
$"spotify:playlist:{playlist.Name}",
$"spotify:missing:{playlist.Name}",
$"spotify:matched:{playlist.Name}",
$"spotify:matched:ordered:{playlist.Name}"
};
foreach (var key in keysToDelete)
{
if (await _cache.DeleteAsync(key))
{
clearedRedisKeys++;
_logger.LogInformation("Cleared Redis cache key: {Key}", key);
}
}
} }
return Ok(new { message = "Cache cleared", filesDeleted = clearedFiles }); _logger.LogInformation("Cache cleared: {Files} files, {RedisKeys} Redis keys", clearedFiles, clearedRedisKeys);
return Ok(new {
message = "Cache cleared successfully",
filesDeleted = clearedFiles,
redisKeysDeleted = clearedRedisKeys
});
} }
/// <summary> /// <summary>