mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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
This commit is contained in:
38
internal/cache/size.go
vendored
38
internal/cache/size.go
vendored
@@ -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,
|
||||
|
Reference in New Issue
Block a user