[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>
This commit is contained in:
kim 2022-11-20 16:33:49 +00:00 committed by GitHub
commit 5d55e8d920
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 319 additions and 80 deletions

View file

@ -166,6 +166,7 @@ func NewBunDBService(ctx context.Context) (db.DB, error) {
notif := &notificationDB{conn: conn}
status := &statusDB{conn: conn}
emoji := &emojiDB{conn: conn}
relationship := &relationshipDB{conn: conn}
timeline := &timelineDB{conn: conn}
tombstone := &tombstoneDB{conn: conn}
user := &userDB{conn: conn}
@ -174,6 +175,7 @@ func NewBunDBService(ctx context.Context) (db.DB, error) {
account.emojis = emoji
account.status = status
admin.users = user
relationship.accounts = account
status.accounts = account
status.emojis = emoji
status.mentions = mention
@ -185,6 +187,7 @@ func NewBunDBService(ctx context.Context) (db.DB, error) {
emoji.init()
mention.init()
notif.init()
relationship.init()
status.init()
tombstone.init()
user.init()
@ -209,9 +212,7 @@ func NewBunDBService(ctx context.Context) (db.DB, error) {
},
Mention: mention,
Notification: notif,
Relationship: &relationshipDB{
conn: conn,
},
Relationship: relationship,
Session: &sessionDB{
conn: conn,
},