diff options
author | 2022-11-20 16:33:49 +0000 | |
---|---|---|
committer | 2022-11-20 16:33:49 +0000 | |
commit | 5d55e8d920cd5969e5cff567ee88afb13f40a1b9 (patch) | |
tree | 7ad27cd4ae90a124a8d5ec04e7ff5ac9a1d27d26 /internal/federation | |
parent | [bugfix] fix possible infinite loop on federated AP profile delete (#1091) (diff) | |
download | gotosocial-5d55e8d920cd5969e5cff567ee88afb13f40a1b9.tar.xz |
[performance] add account block DB cache and remove block query joins (#1085)
* add account block DB cache and remove reliance on relational joins
* actually include cache key arguments...
* add a PutBlock() method which also updates the block cache, update tests accordingly
* use `PutBlock` instead of `Put(ctx, block)`
* add + use functions for deleting + invalidating blocks
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
Diffstat (limited to 'internal/federation')
-rw-r--r-- | internal/federation/federatingdb/create.go | 2 | ||||
-rw-r--r-- | internal/federation/federatingdb/undo.go | 2 | ||||
-rw-r--r-- | internal/federation/federatingprotocol_test.go | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/internal/federation/federatingdb/create.go b/internal/federation/federatingdb/create.go index 25e961bc3..67f076ab3 100644 --- a/internal/federation/federatingdb/create.go +++ b/internal/federation/federatingdb/create.go @@ -103,7 +103,7 @@ func (f *federatingDB) activityBlock(ctx context.Context, asType vocab.Type, rec } block.ID = newID - if err := f.db.Put(ctx, block); err != nil { + if err := f.db.PutBlock(ctx, block); err != nil { return fmt.Errorf("activityBlock: database error inserting block: %s", err) } diff --git a/internal/federation/federatingdb/undo.go b/internal/federation/federatingdb/undo.go index 4cb3d0fa8..792297683 100644 --- a/internal/federation/federatingdb/undo.go +++ b/internal/federation/federatingdb/undo.go @@ -114,7 +114,7 @@ func (f *federatingDB) Undo(ctx context.Context, undo vocab.ActivityStreamsUndo) return errors.New("UNDO: block object account and inbox account were not the same") } // delete any existing BLOCK - if err := f.db.DeleteWhere(ctx, []db.Where{{Key: "uri", Value: gtsBlock.URI}}, >smodel.Block{}); err != nil { + if err := f.db.DeleteBlockByURI(ctx, gtsBlock.URI); err != nil { return fmt.Errorf("UNDO: db error removing block: %s", err) } l.Debug("block undone") diff --git a/internal/federation/federatingprotocol_test.go b/internal/federation/federatingprotocol_test.go index 1eb5f133c..69ce1a6c0 100644 --- a/internal/federation/federatingprotocol_test.go +++ b/internal/federation/federatingprotocol_test.go @@ -312,7 +312,7 @@ func (suite *FederatingProtocolTestSuite) TestBlocked2() { ctxWithOtherInvolvedIRIs := context.WithValue(ctxWithRequestingAccount, ap.ContextOtherInvolvedIRIs, otherInvolvedIRIs) // insert a block from inboxAccount targeting sendingAccount - if err := suite.db.Put(context.Background(), >smodel.Block{ + if err := suite.db.PutBlock(context.Background(), >smodel.Block{ ID: "01G3KBEMJD4VQ2D615MPV7KTRD", URI: "whatever", AccountID: inboxAccount.ID, @@ -350,7 +350,7 @@ func (suite *FederatingProtocolTestSuite) TestBlocked3() { ctxWithOtherInvolvedIRIs := context.WithValue(ctxWithRequestingAccount, ap.ContextOtherInvolvedIRIs, otherInvolvedIRIs) // insert a block from inboxAccount targeting CCed account - if err := suite.db.Put(context.Background(), >smodel.Block{ + if err := suite.db.PutBlock(context.Background(), >smodel.Block{ ID: "01G3KBEMJD4VQ2D615MPV7KTRD", URI: "whatever", AccountID: inboxAccount.ID, |