mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 13:06:50 +00:00
Properly invalidate account caches when deleting systems
This commit is contained in:
parent
ab39ebc512
commit
de427d8bfe
2 changed files with 19 additions and 4 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
|
@ -26,6 +27,16 @@ namespace PluralKit.Core
|
|||
|
||||
public Task InvalidateSystem(PKSystem system) => InvalidateSystem(system.Id);
|
||||
|
||||
public void InvalidateDeletedSystem(int systemId, IEnumerable<ulong> accounts)
|
||||
{
|
||||
// Used when the system's already removed so we can't look up accounts
|
||||
// We assume the account list is saved already somewhere and can be passed here (which is the case in Store)
|
||||
|
||||
_cache.Remove(KeyForSystem(systemId));
|
||||
foreach (var account in accounts)
|
||||
_cache.Remove(KeyForAccount(account));
|
||||
}
|
||||
|
||||
public async Task InvalidateSystem(int systemId)
|
||||
{
|
||||
if (_cache.TryGetValue<CachedAccount>(KeyForSystem(systemId), out var systemCache))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue