Initial cleaner is for expiring access tokens
This commit is contained in:
parent
6f16289b41
commit
4ef9e19fbc
2 changed files with 89 additions and 0 deletions
19
storage-new/cleaners/ExpireAccessTokens.go
Normal file
19
storage-new/cleaners/ExpireAccessTokens.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package cleaners
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.mstar.dev/mstar/linstrom/storage-new/dbgen"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cleanerBuilders = append(cleanerBuilders, buildExpireAccessTokens)
|
||||
}
|
||||
|
||||
func tickExpireAccessTokens(now time.Time) {
|
||||
dbgen.AccessToken.Where(dbgen.AccessToken.ExpiresAt.Lt(time.Now())).Delete()
|
||||
}
|
||||
|
||||
func buildExpireAccessTokens() (onTick func(time.Time), name string, tickSpeed time.Duration) {
|
||||
return tickExpireAccessTokens, "expire-access-tokens", time.Hour
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue