mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-10 07:47:53 +00:00
Rework caching
This does a *lot* of things. Essentially, it replaces the existing individual proxy- and autoproxy caches on the bot end with a global cache (in Core) that handles all the caching at once, and automatically invalidates the cache once something changes in the datastore. This allows us to do proxying and autoproxying with *zero database queries* (best-case).
This commit is contained in:
parent
125ea81ec3
commit
82dfe43d5a
16 changed files with 254 additions and 255 deletions
|
|
@ -17,13 +17,11 @@ namespace PluralKit.Bot.Commands
|
|||
{
|
||||
private IDataStore _data;
|
||||
private EmbedService _embeds;
|
||||
private ProxyCacheService _proxyCache;
|
||||
|
||||
public SystemEdit(IDataStore data, EmbedService embeds, ProxyCacheService proxyCache)
|
||||
public SystemEdit(IDataStore data, EmbedService embeds)
|
||||
{
|
||||
_data = data;
|
||||
_embeds = embeds;
|
||||
_proxyCache = proxyCache;
|
||||
}
|
||||
|
||||
public async Task Name(Context ctx)
|
||||
|
|
@ -62,8 +60,6 @@ namespace PluralKit.Bot.Commands
|
|||
|
||||
await _data.SaveSystem(ctx.System);
|
||||
await ctx.Reply($"{Emojis.Success} System tag {(newTag != null ? $"changed. Member names will now end with `{newTag.SanitizeMentions()}` when proxied" : "cleared")}.");
|
||||
|
||||
await _proxyCache.InvalidateResultsForSystem(ctx.System);
|
||||
}
|
||||
|
||||
public async Task Avatar(Context ctx)
|
||||
|
|
@ -115,8 +111,6 @@ namespace PluralKit.Bot.Commands
|
|||
var embed = url != null ? new EmbedBuilder().WithImageUrl(url).Build() : null;
|
||||
await ctx.Reply($"{Emojis.Success} System avatar changed.", embed: embed);
|
||||
}
|
||||
|
||||
await _proxyCache.InvalidateResultsForSystem(ctx.System);
|
||||
}
|
||||
|
||||
public async Task Delete(Context ctx) {
|
||||
|
|
@ -128,8 +122,6 @@ namespace PluralKit.Bot.Commands
|
|||
|
||||
await _data.DeleteSystem(ctx.System);
|
||||
await ctx.Reply($"{Emojis.Success} System deleted.");
|
||||
|
||||
await _proxyCache.InvalidateResultsForSystem(ctx.System);
|
||||
}
|
||||
|
||||
public async Task SystemProxy(Context ctx)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue