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