From f79d50b9b26590b6d2468aeb41f0846272e08d1a Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Mon, 15 Apr 2024 14:22:21 +0100 Subject: [performance] cached oauth database types (#2838) * update token + client code to use struct caches * add code comments * slight tweak to default mem ratios * fix envparsing * add appropriate invalidate hooks * update the tokenstore sweeping function to rely on caches * update to use PutClient() * add ClientID to list of token struct indices --- internal/cache/invalidate.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'internal/cache/invalidate.go') diff --git a/internal/cache/invalidate.go b/internal/cache/invalidate.go index 746d8c7e7..547015eac 100644 --- a/internal/cache/invalidate.go +++ b/internal/cache/invalidate.go @@ -60,6 +60,11 @@ func (c *Caches) OnInvalidateAccount(account *gtsmodel.Account) { c.GTS.Move.Invalidate("TargetURI", account.URI) } +func (c *Caches) OnInvalidateApplication(app *gtsmodel.Application) { + // Invalidate cached client of this application. + c.GTS.Client.Invalidate("ID", app.ClientID) +} + func (c *Caches) OnInvalidateBlock(block *gtsmodel.Block) { // Invalidate block origin account ID cached visibility. c.Visibility.Invalidate("ItemID", block.AccountID) @@ -73,6 +78,11 @@ func (c *Caches) OnInvalidateBlock(block *gtsmodel.Block) { c.GTS.BlockIDs.Invalidate(block.AccountID) } +func (c *Caches) OnInvalidateClient(client *gtsmodel.Client) { + // Invalidate any tokens under this client. + c.GTS.Token.Invalidate("ClientID", client.ID) +} + func (c *Caches) OnInvalidateEmojiCategory(category *gtsmodel.EmojiCategory) { // Invalidate any emoji in this category. c.GTS.Emoji.Invalidate("CategoryID", category.ID) -- cgit v1.2.3