summaryrefslogtreecommitdiff
path: root/internal/media
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-03-03 23:02:23 +0000
committerLibravatar GitHub <noreply@github.com>2023-03-03 23:02:23 +0000
commita8e6bdfa33f3232ebc8f241b9c90e4da9191a627 (patch)
tree087eca372fb13093f39837683682ca9e11b96188 /internal/media
parent[bugfix] Federate status delete using just the URI (#1584) (diff)
downloadgotosocial-a8e6bdfa33f3232ebc8f241b9c90e4da9191a627.tar.xz
[performance] cache media attachments (#1525)
* replace concurrency worker pools with base models in State.Workers, update code and tests accordingly * add media attachment caching, slightly tweak default cache config * further tweak default cache config values * replace other media attachment db calls to go through cache * update envparsing test * fix delete media attachment sql * fix media sql query * invalidate cached media entries during status create / update * fix envparsing test * fix typo in panic log message... * add 'updated_at' column during UpdateAttachment * remove unused func --------- Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/media')
-rw-r--r--internal/media/processingmedia.go8
-rw-r--r--internal/media/prune.go4
2 files changed, 6 insertions, 6 deletions
diff --git a/internal/media/processingmedia.go b/internal/media/processingmedia.go
index c00c203a6..a315fa387 100644
--- a/internal/media/processingmedia.go
+++ b/internal/media/processingmedia.go
@@ -123,13 +123,13 @@ func (p *ProcessingMedia) load(ctx context.Context) (*gtsmodel.MediaAttachment,
}
if p.recache {
- // Existing attachment we're recaching, so only need to update.
- err = p.mgr.state.DB.UpdateByID(ctx, p.media, p.media.ID)
+ // Existing attachment we're recaching, so only update.
+ err = p.mgr.state.DB.UpdateAttachment(ctx, p.media)
return err
}
- // New attachment, first time caching.
- err = p.mgr.state.DB.Put(ctx, p.media)
+ // First time caching this attachment, insert it.
+ err = p.mgr.state.DB.PutAttachment(ctx, p.media)
return err
})
diff --git a/internal/media/prune.go b/internal/media/prune.go
index 9e73fd2a3..aeddcef4c 100644
--- a/internal/media/prune.go
+++ b/internal/media/prune.go
@@ -320,7 +320,7 @@ func (m *manager) deleteAttachment(ctx context.Context, attachment *gtsmodel.Med
}
// Delete attachment completely.
- return m.state.DB.DeleteByID(ctx, attachment.ID, attachment)
+ return m.state.DB.DeleteAttachment(ctx, attachment.ID)
}
func (m *manager) uncacheAttachment(ctx context.Context, attachment *gtsmodel.MediaAttachment) error {
@@ -332,7 +332,7 @@ func (m *manager) uncacheAttachment(ctx context.Context, attachment *gtsmodel.Me
attachment.UpdatedAt = time.Now()
cached := false
attachment.Cached = &cached
- return m.state.DB.UpdateByID(ctx, attachment, attachment.ID, "updated_at", "cached")
+ return m.state.DB.UpdateAttachment(ctx, attachment, "updated_at", "cached")
}
func (m *manager) removeFiles(ctx context.Context, keys ...string) (int, error) {