mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
cf7a906023
* fix: project by id loads project from view and from eventstore * fix: correct search key for role * feat(auth): my user changes * fix: improve error handling in change converters * fix: log-id
36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
package eventsourcing
|
|
|
|
import (
|
|
"github.com/caos/logging"
|
|
"github.com/caos/zitadel/internal/cache"
|
|
"github.com/caos/zitadel/internal/cache/config"
|
|
"github.com/caos/zitadel/internal/eventstore/models"
|
|
"github.com/caos/zitadel/internal/user/repository/eventsourcing/model"
|
|
)
|
|
|
|
type UserCache struct {
|
|
userCache cache.Cache
|
|
}
|
|
|
|
func StartCache(conf *config.CacheConfig) (*UserCache, error) {
|
|
userCache, err := conf.Config.NewCache()
|
|
logging.Log("EVENT-vJG2j").OnError(err).Panic("unable to create user cache")
|
|
|
|
return &UserCache{userCache: userCache}, nil
|
|
}
|
|
|
|
func (c *UserCache) getUser(ID string) *model.User {
|
|
user := &model.User{ObjectRoot: models.ObjectRoot{AggregateID: ID}}
|
|
if err := c.userCache.Get(ID, user); err != nil {
|
|
logging.Log("EVENT-AtS0S").WithError(err).Debug("error in getting cache")
|
|
}
|
|
return user
|
|
}
|
|
|
|
func (c *UserCache) cacheUser(user *model.User) {
|
|
err := c.userCache.Set(user.AggregateID, user)
|
|
if err != nil {
|
|
logging.Log("EVENT-0V2gX").WithError(err).Debug("error in setting project cache")
|
|
}
|
|
}
|