kopia lustrzana https://codeberg.org/nmkj/audon
increase session cacche ttl
rodzic
db42f13ee4
commit
150ad6df05
2
auth.go
2
auth.go
|
@ -8,6 +8,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/jellydator/ttlcache/v3"
|
||||
"github.com/labstack/echo/v4"
|
||||
mastodon "github.com/mattn/go-mastodon"
|
||||
"github.com/oklog/ulid/v2"
|
||||
|
@ -228,6 +229,7 @@ func authMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
|
|||
data, err := getSessionData(c)
|
||||
if err == nil && data.AudonID != "" {
|
||||
if user, err := findUserByID(c.Request().Context(), data.AudonID); err == nil {
|
||||
userSessionCache.Set(data.AudonID, data, ttlcache.DefaultTTL)
|
||||
c.Set("user", user)
|
||||
c.Set("data", data)
|
||||
return next(c)
|
||||
|
|
2
room.go
2
room.go
|
@ -415,8 +415,6 @@ func joinRoomHandler(c echo.Context) (err error) {
|
|||
}
|
||||
|
||||
// Store user's session data in cache
|
||||
data, _ := getSessionData(c)
|
||||
userSessionCache.Set(user.AudonID, data, ttlcache.DefaultTTL)
|
||||
orphanRooms.Delete(roomID)
|
||||
|
||||
return c.JSON(http.StatusOK, resp)
|
||||
|
|
|
@ -155,8 +155,8 @@ func main() {
|
|||
e.Use(session.Middleware(redisStore))
|
||||
|
||||
// Setup caches
|
||||
userSessionCache = ttlcache.New(ttlcache.WithTTL[string, *SessionData](24 * time.Hour))
|
||||
webhookTimerCache = ttlcache.New(ttlcache.WithTTL[string, *time.Timer](60 * time.Second))
|
||||
userSessionCache = ttlcache.New(ttlcache.WithTTL[string, *SessionData](168 * time.Hour))
|
||||
webhookTimerCache = ttlcache.New(ttlcache.WithTTL[string, *time.Timer](5 * time.Minute))
|
||||
orphanRooms = ttlcache.New(ttlcache.WithTTL[string, bool](24 * time.Hour))
|
||||
go userSessionCache.Start()
|
||||
go webhookTimerCache.Start()
|
||||
|
|
|
@ -92,7 +92,6 @@ func livekitWebhookHandler(c echo.Context) error {
|
|||
log.Println(err)
|
||||
}
|
||||
nextUser.ClearUserAvatar(ctx)
|
||||
userSessionCache.Delete(audonID)
|
||||
} else if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue