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/size.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/size.go')
-rw-r--r-- | internal/cache/size.go | 38 |
1 files changed, 37 insertions, 1 deletions
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, |