wp-go/internal/cache/users.go

27 lines
674 B
Go
Raw Normal View History

2023-01-12 12:42:16 +00:00
package cache
import (
"context"
2023-01-13 06:04:32 +00:00
"github/fthvgb1/wp-go/internal/pkg/logs"
"github/fthvgb1/wp-go/internal/pkg/models"
2023-01-12 12:42:16 +00:00
"github/fthvgb1/wp-go/model"
"time"
)
func getUserById(a ...any) (r models.Users, err error) {
ctx := a[0].(context.Context)
uid := a[1].(uint64)
r, err = model.FindOneById[models.Users](ctx, uid)
return
}
func GetUserByName(ctx context.Context, username string) (models.Users, error) {
return usersNameCache.GetCache(ctx, username, time.Second, ctx, username)
}
func GetUserById(ctx context.Context, uid uint64) models.Users {
r, err := usersCache.GetCache(ctx, uid, time.Second, ctx, uid)
logs.ErrPrintln(err, "get user", uid)
return r
}