diff options
author | 2024-04-15 14:22:21 +0100 | |
---|---|---|
committer | 2024-04-15 14:22:21 +0100 | |
commit | f79d50b9b26590b6d2468aeb41f0846272e08d1a (patch) | |
tree | 196b9bfaf8ad6fce782c2130633cfb5c97cbd31a /internal/cache/invalidate.go | |
parent | [chore] Turn `accounts-registration-open` false by default (#2839) (diff) | |
download | gotosocial-f79d50b9b26590b6d2468aeb41f0846272e08d1a.tar.xz |
[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
Diffstat (limited to 'internal/cache/invalidate.go')
-rw-r--r-- | internal/cache/invalidate.go | 10 |
1 files changed, 10 insertions, 0 deletions
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) |