wrap UpdateToken with cache

This commit is contained in:
tobi 2025-03-03 14:39:11 +01:00
commit 13c03a8909

View file

@ -199,18 +199,15 @@ func (a *applicationDB) PutToken(ctx context.Context, token *gtsmodel.Token) err
} }
func (a *applicationDB) UpdateToken(ctx context.Context, token *gtsmodel.Token, columns ...string) error { func (a *applicationDB) UpdateToken(ctx context.Context, token *gtsmodel.Token, columns ...string) error {
_, err := a.db. return a.state.Caches.DB.Token.Store(token, func() error {
NewUpdate(). _, err := a.db.
Model(token). NewUpdate().
Column(columns...). Model(token).
Where("? = ?", bun.Ident("id"), token.ID). Column(columns...).
Exec(ctx) Where("? = ?", bun.Ident("id"), token.ID).
if err != nil { Exec(ctx)
return err return err
} })
a.state.Caches.DB.Token.Invalidate("ID", token.ID)
return nil
} }
func (a *applicationDB) DeleteTokenByID(ctx context.Context, id string) error { func (a *applicationDB) DeleteTokenByID(ctx context.Context, id string) error {