mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
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:
@@ -838,6 +838,7 @@ public class AdminController : ControllerBase
|
||||
_logger.LogInformation("Cache clear requested from admin UI");
|
||||
|
||||
var clearedFiles = 0;
|
||||
var clearedRedisKeys = 0;
|
||||
|
||||
// Clear file cache
|
||||
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)
|
||||
{
|
||||
await _cache.DeleteAsync($"spotify:playlist:{playlist.Name}");
|
||||
await _cache.DeleteAsync($"spotify:missing:{playlist.Name}");
|
||||
var keysToDelete = new[]
|
||||
{
|
||||
$"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>
|
||||
|
||||
Reference in New Issue
Block a user