mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 16:02:55 +08:00
Difficulty cache invalidation flow
This commit is contained in:
parent
66a01d1ed2
commit
30b3973c9f
@ -81,6 +81,11 @@ namespace osu.Game.Beatmaps
|
||||
}, true);
|
||||
}
|
||||
|
||||
public void Invalidate(IBeatmapInfo beatmap)
|
||||
{
|
||||
base.Invalidate(lookup => lookup.BeatmapInfo.Equals(beatmap));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a bindable containing the star difficulty of a <see cref="BeatmapInfo"/> that follows the currently-selected ruleset and mods.
|
||||
/// </summary>
|
||||
|
@ -61,6 +61,8 @@ namespace osu.Game.Beatmaps
|
||||
var working = workingBeatmapCache.GetWorkingBeatmap(beatmap);
|
||||
beatmap.Length = calculateLength(working.Beatmap);
|
||||
beatmap.BPM = 60000 / working.Beatmap.GetMostCommonBeatLength();
|
||||
|
||||
difficultyCache.Invalidate(beatmap);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@ -39,6 +40,15 @@ namespace osu.Game.Database
|
||||
return computed;
|
||||
}
|
||||
|
||||
protected void Invalidate(Func<TLookup, bool> invalidationFunction)
|
||||
{
|
||||
foreach (var kvp in cache)
|
||||
{
|
||||
if (invalidationFunction(kvp.Key))
|
||||
cache.TryRemove(kvp.Key, out _);
|
||||
}
|
||||
}
|
||||
|
||||
protected bool CheckExists([NotNull] TLookup lookup, out TValue value) =>
|
||||
cache.TryGetValue(lookup, out value);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user