mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 19:02:26 -05:00
[performance] temporarily cache account status counts to reduce no. account counts (#2620)
* temporarily cache account status counts to reduce no. account counts
* whoops, forgot to initAccountCounts()
* use already fetched cache capacity value
* make cache a ptr type
* whoops, use count instead of just select
* fix to correctly use the transaction
* properly wrap that tx 😇
* correctly wrap both tx types
* outline retryOnBusy() to allow the fast path to be inlined
* return err on context cancelled
* remove unnecessary storage of context in stmt, fix Exec and Query interface implementations
* shutup linter
This commit is contained in:
parent
b2675047cb
commit
ede8f43635
5 changed files with 199 additions and 38 deletions
6
internal/cache/invalidate.go
vendored
6
internal/cache/invalidate.go
vendored
|
|
@ -27,6 +27,9 @@ import (
|
|||
// HOOKS TO BE CALLED ON DELETE YOU MUST FIRST POPULATE IT IN THE CACHE.
|
||||
|
||||
func (c *Caches) OnInvalidateAccount(account *gtsmodel.Account) {
|
||||
// Invalidate status counts for this account.
|
||||
c.GTS.AccountCounts.Invalidate(account.ID)
|
||||
|
||||
// Invalidate account ID cached visibility.
|
||||
c.Visibility.Invalidate("ItemID", account.ID)
|
||||
c.Visibility.Invalidate("RequesterID", account.ID)
|
||||
|
|
@ -151,6 +154,9 @@ func (c *Caches) OnInvalidatePollVote(vote *gtsmodel.PollVote) {
|
|||
}
|
||||
|
||||
func (c *Caches) OnInvalidateStatus(status *gtsmodel.Status) {
|
||||
// Invalidate status counts for this account.
|
||||
c.GTS.AccountCounts.Invalidate(status.AccountID)
|
||||
|
||||
// Invalidate status ID cached visibility.
|
||||
c.Visibility.Invalidate("ItemID", status.ID)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue