mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-23 03:06:14 -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 {
|
||||
_, err := a.db.
|
||||
NewUpdate().
|
||||
Model(token).
|
||||
Column(columns...).
|
||||
Where("? = ?", bun.Ident("id"), token.ID).
|
||||
Exec(ctx)
|
||||
if err != nil {
|
||||
return a.state.Caches.DB.Token.Store(token, func() error {
|
||||
_, err := a.db.
|
||||
NewUpdate().
|
||||
Model(token).
|
||||
Column(columns...).
|
||||
Where("? = ?", bun.Ident("id"), token.ID).
|
||||
Exec(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
a.state.Caches.DB.Token.Invalidate("ID", token.ID)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (a *applicationDB) DeleteTokenByID(ctx context.Context, id string) error {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue