mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-23 00:16:16 -06:00
wrap UpdateToken with cache
This commit is contained in:
parent
a676bd3602
commit
13c03a8909
1 changed files with 8 additions and 11 deletions
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue