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 {
return a.state.Caches.DB.Token.Store(token, func() error {
_, err := a.db. _, err := a.db.
NewUpdate(). NewUpdate().
Model(token). Model(token).
Column(columns...). Column(columns...).
Where("? = ?", bun.Ident("id"), token.ID). Where("? = ?", bun.Ident("id"), token.ID).
Exec(ctx) Exec(ctx)
if err != nil {
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 {