Don't actively remove cached recommendations, let them expire.

This commit is contained in:
BtbN 2019-06-06 18:34:37 +02:00
parent 09307826e8
commit fe568f7576
2 changed files with 3 additions and 6 deletions

View File

@ -20,11 +20,9 @@ namespace ClanServer.Controllers.L44
public class GametopController : ControllerBase
{
private readonly ClanServerContext ctx;
private readonly IMemoryCache cache;
public GametopController(IMemoryCache cache, ClanServerContext ctx)
public GametopController(ClanServerContext ctx)
{
this.cache = cache;
this.ctx = ctx;
}
@ -163,8 +161,6 @@ namespace ClanServer.Controllers.L44
bool changed = false;
bool freshProfile = false;
cache.Remove(CacheKeys.GetRecommendedSongsKey(profile.ID));
if (profile.ClanData == null)
{
Random rng = new Random();

View File

@ -34,7 +34,8 @@ namespace ClanServer.Controllers.L44
List<int> recommendedMusic =
await cache.GetOrCreateAsync(CacheKeys.GetRecommendedSongsKey(jid), async entry =>
{
entry.SlidingExpiration = TimeSpan.FromMinutes(30);
entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30);
entry.SlidingExpiration = TimeSpan.FromMinutes(2);
return (await ClanMusicInfo.Instance).GetRandomSongs(10);
});