3using System.Threading.Tasks;
4using CommunityToolkit.Mvvm.Messaging;
11 internal sealed
class CacheInvalidationService : ICacheInvalidationService
15 public CacheInvalidationService() : this(
ServiceRef.InternetCacheService) { }
21 public async Task<int> InvalidateByParentId(
string parentId,
string scope)
24 WeakReferenceMessenger.Default.Send(
new CacheInvalidatedMessage(scope, parentId,
null));
28 public async Task<int> InvalidateByKeys(IEnumerable<string> keys,
string scope)
31 foreach (
string key
in keys ?? Enumerable.Empty<
string>())
33 if (await this.cache.Remove(
new System.Uri(key)).ConfigureAwait(
false))
36 WeakReferenceMessenger.Default.Send(
new CacheInvalidatedMessage(scope,
null, keys?.ToList()));
Base class that references services in the app.
Defines operations for caching arbitrary internet-fetchable content.
Task< int > RemoveByParentId(string ParentId)
Removes all cached entries having the specified parent ID.