mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-17 05:18:04 +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.1 KiB
Go
36 lines
1.1 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/project/repository/eventsourcing/model"
|
|
)
|
|
|
|
type ProjectCache struct {
|
|
projectCache cache.Cache
|
|
}
|
|
|
|
func StartCache(conf *config.CacheConfig) (*ProjectCache, error) {
|
|
projectCache, err := conf.Config.NewCache()
|
|
logging.Log("EVENT-CsHdo").OnError(err).Panic("unable to create project cache")
|
|
|
|
return &ProjectCache{projectCache: projectCache}, nil
|
|
}
|
|
|
|
func (c *ProjectCache) getProject(ID string) (project *model.Project) {
|
|
project = &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: ID}}
|
|
if err := c.projectCache.Get(ID, project); err != nil {
|
|
logging.Log("EVENT-tMydV").WithError(err).Debug("error in getting cache")
|
|
}
|
|
return project
|
|
}
|
|
|
|
func (c *ProjectCache) cacheProject(project *model.Project) {
|
|
err := c.projectCache.Set(project.AggregateID, project)
|
|
if err != nil {
|
|
logging.Log("EVENT-3wKzj").WithError(err).Debug("error in setting project cache")
|
|
}
|
|
}
|