summaryrefslogtreecommitdiff
path: root/internal/db/bundb/relationship_follow_req.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-07-31 11:25:29 +0100
committerLibravatar GitHub <noreply@github.com>2023-07-31 11:25:29 +0100
commited2477ebea4c3ceec5949821f4950db9669a4a15 (patch)
tree1038d7abdfc787ddfc1febb326fd38775b189b85 /internal/db/bundb/relationship_follow_req.go
parent[bugfix/frontend] Decode URI component domain before showing on frontend (#2043) (diff)
downloadgotosocial-ed2477ebea4c3ceec5949821f4950db9669a4a15.tar.xz
[performance] cache follow, follow request and block ID lists (#2027)
Diffstat (limited to 'internal/db/bundb/relationship_follow_req.go')
-rw-r--r--internal/db/bundb/relationship_follow_req.go25
1 files changed, 12 insertions, 13 deletions
diff --git a/internal/db/bundb/relationship_follow_req.go b/internal/db/bundb/relationship_follow_req.go
index a6e913953..dc5e760e6 100644
--- a/internal/db/bundb/relationship_follow_req.go
+++ b/internal/db/bundb/relationship_follow_req.go
@@ -208,9 +208,6 @@ func (r *relationshipDB) AcceptFollowRequest(ctx context.Context, sourceAccountI
return nil, err
}
- // Invalidate follow request from cache lookups on return.
- defer r.state.Caches.GTS.FollowRequest().Invalidate("ID", followReq.ID)
-
// Delete original follow request.
if _, err := r.db.
NewDelete().
@@ -243,8 +240,6 @@ func (r *relationshipDB) RejectFollowRequest(ctx context.Context, sourceAccountI
}
func (r *relationshipDB) DeleteFollowRequest(ctx context.Context, sourceAccountID string, targetAccountID string) error {
- defer r.state.Caches.GTS.FollowRequest().Invalidate("AccountID.TargetAccountID", sourceAccountID, targetAccountID)
-
// Load followreq into cache before attempting a delete,
// as we need it cached in order to trigger the invalidate
// callback. This in turn invalidates others.
@@ -261,6 +256,9 @@ func (r *relationshipDB) DeleteFollowRequest(ctx context.Context, sourceAccountI
return err
}
+ // Drop this now-cached follow request on return after delete.
+ defer r.state.Caches.GTS.FollowRequest().Invalidate("AccountID.TargetAccountID", sourceAccountID, targetAccountID)
+
// Finally delete followreq from DB.
_, err = r.db.NewDelete().
Table("follow_requests").
@@ -270,8 +268,6 @@ func (r *relationshipDB) DeleteFollowRequest(ctx context.Context, sourceAccountI
}
func (r *relationshipDB) DeleteFollowRequestByID(ctx context.Context, id string) error {
- defer r.state.Caches.GTS.FollowRequest().Invalidate("ID", id)
-
// Load followreq into cache before attempting a delete,
// as we need it cached in order to trigger the invalidate
// callback. This in turn invalidates others.
@@ -284,6 +280,9 @@ func (r *relationshipDB) DeleteFollowRequestByID(ctx context.Context, id string)
return err
}
+ // Drop this now-cached follow request on return after delete.
+ defer r.state.Caches.GTS.FollowRequest().Invalidate("ID", id)
+
// Finally delete followreq from DB.
_, err = r.db.NewDelete().
Table("follow_requests").
@@ -293,8 +292,6 @@ func (r *relationshipDB) DeleteFollowRequestByID(ctx context.Context, id string)
}
func (r *relationshipDB) DeleteFollowRequestByURI(ctx context.Context, uri string) error {
- defer r.state.Caches.GTS.FollowRequest().Invalidate("URI", uri)
-
// Load followreq into cache before attempting a delete,
// as we need it cached in order to trigger the invalidate
// callback. This in turn invalidates others.
@@ -307,6 +304,9 @@ func (r *relationshipDB) DeleteFollowRequestByURI(ctx context.Context, uri strin
return err
}
+ // Drop this now-cached follow request on return after delete.
+ defer r.state.Caches.GTS.FollowRequest().Invalidate("URI", uri)
+
// Finally delete followreq from DB.
_, err = r.db.NewDelete().
Table("follow_requests").
@@ -334,10 +334,9 @@ func (r *relationshipDB) DeleteAccountFollowRequests(ctx context.Context, accoun
}
defer func() {
- // Invalidate all IDs on return.
- for _, id := range followReqIDs {
- r.state.Caches.GTS.FollowRequest().Invalidate("ID", id)
- }
+ // Invalidate all account's incoming / outoing follow requests on return.
+ r.state.Caches.GTS.FollowRequest().Invalidate("AccountID", accountID)
+ r.state.Caches.GTS.FollowRequest().Invalidate("TargetAccountID", accountID)
}()
// Load all followreqs into cache, this *really* isn't