Difficulty cache invalidation flow

This commit is contained in:
Dean Herbert
2022-06-24 18:39:44 +09:00
parent 66a01d1ed2
commit 30b3973c9f
3 changed files with 17 additions and 0 deletions

View File

@ -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);