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/size.go | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'internal/cache/size.go') diff --git a/internal/cache/size.go b/internal/cache/size.go index 83b0da046..9c1a82abc 100644 --- a/internal/cache/size.go +++ b/internal/cache/size.go @@ -176,6 +176,7 @@ func totalOfRatios() float64 { config.GetCacheBlockMemRatio() + config.GetCacheBlockIDsMemRatio() + config.GetCacheBoostOfIDsMemRatio() + + config.GetCacheClientMemRatio() + config.GetCacheEmojiMemRatio() + config.GetCacheEmojiCategoryMemRatio() + config.GetCacheFollowMemRatio() + @@ -198,6 +199,7 @@ func totalOfRatios() float64 { config.GetCacheStatusFaveIDsMemRatio() + config.GetCacheTagMemRatio() + config.GetCacheThreadMuteMemRatio() + + config.GetCacheTokenMemRatio() + config.GetCacheTombstoneMemRatio() + config.GetCacheUserMemRatio() + config.GetCacheWebfingerMemRatio() + @@ -287,6 +289,17 @@ func sizeofBlock() uintptr { })) } +func sizeofClient() uintptr { + return uintptr(size.Of(>smodel.Client{ + ID: exampleID, + CreatedAt: exampleTime, + UpdatedAt: exampleTime, + Secret: exampleID, + Domain: exampleURI, + UserID: exampleID, + })) +} + func sizeofEmoji() uintptr { return uintptr(size.Of(>smodel.Emoji{ ID: exampleID, @@ -591,7 +604,7 @@ func sizeofTag() uintptr { })) } -func sizeOfThreadMute() uintptr { +func sizeofThreadMute() uintptr { return uintptr(size.Of(>smodel.ThreadMute{ ID: exampleID, CreatedAt: exampleTime, @@ -601,6 +614,29 @@ func sizeOfThreadMute() uintptr { })) } +func sizeofToken() uintptr { + return uintptr(size.Of(>smodel.Token{ + ID: exampleID, + CreatedAt: exampleTime, + UpdatedAt: exampleTime, + ClientID: exampleID, + UserID: exampleID, + RedirectURI: exampleURI, + Scope: "r:w", + Code: "", // TODO + CodeChallenge: "", // TODO + CodeChallengeMethod: "", // TODO + CodeCreateAt: exampleTime, + CodeExpiresAt: exampleTime, + Access: exampleID + exampleID, + AccessCreateAt: exampleTime, + AccessExpiresAt: exampleTime, + Refresh: "", // TODO: clients don't really support this very well yet + RefreshCreateAt: exampleTime, + RefreshExpiresAt: exampleTime, + })) +} + func sizeofTombstone() uintptr { return uintptr(size.Of(>smodel.Tombstone{ ID: exampleID, -- cgit v1.2.3