Send and receive SMS messages using your Android phone programmatically via a simple HTTP API
Fix the cache
Acho Arnold7c8444c5a9ca
diff --git a/api/pkg/di/container.go b/api/pkg/di/container.goindex c724e6d4..d6252bf9 100644--- a/api/pkg/di/container.go+++ b/api/pkg/di/container.go@@ -1321,21 +1321,21 @@ func (container *Container) UserRepository() repositories.UserRepository {return repositories.NewGormUserRepository(container.Logger(),container.Tracer(),- container.RistrettoCache(),+ container.UserRistrettoCache(),container.DB(),)}-// RistrettoCache creates an in-memory *ristretto.Cache-func (container *Container) RistrettoCache() (cache *ristretto.Cache) {+// UserRistrettoCache creates an in-memory *ristretto.Cache[string, entities.AuthUser]+func (container *Container) UserRistrettoCache() (cache *ristretto.Cache[string, entities.AuthUser]) {container.logger.Debug(fmt.Sprintf("creating %T", cache))- ristrettoCache, err := ristretto.NewCache(&ristretto.Config{+ ristrettoCache, err := ristretto.NewCache[string, entities.AuthUser](&ristretto.Config[string, entities.AuthUser]{MaxCost: 5000,NumCounters: 5000 * 10,BufferItems: 64,})if err != nil {- container.logger.Fatal(stacktrace.Propagate(err, "cannot create ristretto cache"))+ container.logger.Fatal(stacktrace.Propagate(err, "cannot create user ristretto cache"))}return ristrettoCache}diff --git a/api/pkg/repositories/gorm_user_repository.go b/api/pkg/repositories/gorm_user_repository.goindex f853e323..4857ee86 100644--- a/api/pkg/repositories/gorm_user_repository.go+++ b/api/pkg/repositories/gorm_user_repository.go@@ -23,7 +23,7 @@ import (type gormUserRepository struct {logger telemetry.Loggertracer telemetry.Tracer- cache *ristretto.Cache+ cache *ristretto.Cache[string, entities.AuthUser]db *gorm.DB}@@ -31,7 +31,7 @@ type gormUserRepository struct {func NewGormUserRepository(logger telemetry.Logger,tracer telemetry.Tracer,- cache *ristretto.Cache,+ cache *ristretto.Cache[string, entities.AuthUser],db *gorm.DB,) UserRepository {return &gormUserRepository{@@ -119,8 +119,8 @@ func (repository *gormUserRepository) LoadAuthUser(ctx context.Context, apiKey sdefer span.End()if authUser, found := repository.cache.Get(apiKey); found {- ctxLogger.Info(fmt.Sprintf("cache hit for user with ID [%s]", authUser.(entities.AuthUser).ID))- return authUser.(entities.AuthUser), nil+ ctxLogger.Info(fmt.Sprintf("cache hit for user with ID [%s]", authUser.ID))+ return authUser, nil}user := new(entities.User)