mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-22 00:07:29 -06:00
[chore] renames the GTS caches to DB caches (#3127)
* renames the `GTS` caches to `DB` caches, as it better references what they are * change remaining Caches.GTS uses to Caches.DB
This commit is contained in:
parent
325b4a2b4a
commit
63fc9b6c3e
39 changed files with 376 additions and 378 deletions
|
|
@ -54,7 +54,7 @@ func (m *mediaDB) GetAttachmentByID(ctx context.Context, id string) (*gtsmodel.M
|
|||
|
||||
func (m *mediaDB) GetAttachmentsByIDs(ctx context.Context, ids []string) ([]*gtsmodel.MediaAttachment, error) {
|
||||
// Load all media IDs via cache loader callbacks.
|
||||
media, err := m.state.Caches.GTS.Media.LoadIDs("ID",
|
||||
media, err := m.state.Caches.DB.Media.LoadIDs("ID",
|
||||
ids,
|
||||
func(uncached []string) ([]*gtsmodel.MediaAttachment, error) {
|
||||
// Preallocate expected length of uncached media attachments.
|
||||
|
|
@ -85,7 +85,7 @@ func (m *mediaDB) GetAttachmentsByIDs(ctx context.Context, ids []string) ([]*gts
|
|||
}
|
||||
|
||||
func (m *mediaDB) getAttachment(ctx context.Context, lookup string, dbQuery func(*gtsmodel.MediaAttachment) error, keyParts ...any) (*gtsmodel.MediaAttachment, error) {
|
||||
return m.state.Caches.GTS.Media.LoadOne(lookup, func() (*gtsmodel.MediaAttachment, error) {
|
||||
return m.state.Caches.DB.Media.LoadOne(lookup, func() (*gtsmodel.MediaAttachment, error) {
|
||||
var attachment gtsmodel.MediaAttachment
|
||||
|
||||
// Not cached! Perform database query
|
||||
|
|
@ -98,7 +98,7 @@ func (m *mediaDB) getAttachment(ctx context.Context, lookup string, dbQuery func
|
|||
}
|
||||
|
||||
func (m *mediaDB) PutAttachment(ctx context.Context, media *gtsmodel.MediaAttachment) error {
|
||||
return m.state.Caches.GTS.Media.Store(media, func() error {
|
||||
return m.state.Caches.DB.Media.Store(media, func() error {
|
||||
_, err := m.db.NewInsert().Model(media).Exec(ctx)
|
||||
return err
|
||||
})
|
||||
|
|
@ -111,7 +111,7 @@ func (m *mediaDB) UpdateAttachment(ctx context.Context, media *gtsmodel.MediaAtt
|
|||
columns = append(columns, "updated_at")
|
||||
}
|
||||
|
||||
return m.state.Caches.GTS.Media.Store(media, func() error {
|
||||
return m.state.Caches.DB.Media.Store(media, func() error {
|
||||
_, err := m.db.NewUpdate().
|
||||
Model(media).
|
||||
Where("? = ?", bun.Ident("media_attachment.id"), media.ID).
|
||||
|
|
@ -135,7 +135,7 @@ func (m *mediaDB) DeleteAttachment(ctx context.Context, id string) error {
|
|||
}
|
||||
|
||||
// On return, ensure that media with ID is invalidated.
|
||||
defer m.state.Caches.GTS.Media.Invalidate("ID", id)
|
||||
defer m.state.Caches.DB.Media.Invalidate("ID", id)
|
||||
|
||||
// Delete media attachment in new transaction.
|
||||
err = m.db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue