diff options
author | Michael Muré <batolettre@gmail.com> | 2022-12-19 18:09:59 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2022-12-19 18:09:59 +0100 |
commit | f2def3a9331080a02e57710a859d2aac608ed44c (patch) | |
tree | 2697224efb96110b65489877b5ba7d67d508eb5e /cache/identity_subcache.go | |
parent | 60d40d60e9f91247b61f541888f1469bff44f573 (diff) | |
download | git-bug-f2def3a9331080a02e57710a859d2aac608ed44c.tar.gz |
WIP
Diffstat (limited to 'cache/identity_subcache.go')
-rw-r--r-- | cache/identity_subcache.go | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/cache/identity_subcache.go b/cache/identity_subcache.go index a3b5a0f8..b175d731 100644 --- a/cache/identity_subcache.go +++ b/cache/identity_subcache.go @@ -4,10 +4,39 @@ import ( "fmt" "github.com/MichaelMure/git-bug/entities/identity" + "github.com/MichaelMure/git-bug/entity" + "github.com/MichaelMure/git-bug/repository" ) type RepoCacheIdentity struct { - SubCache[*IdentityExcerpt, *IdentityCache, identity.Interface] + *SubCache[*identity.Identity, *IdentityExcerpt, *IdentityCache] +} + +func NewRepoCacheIdentity(repo repository.ClockedRepo, + resolvers func() entity.Resolvers, + getUserIdentity getUserIdentityFunc) *RepoCacheIdentity { + + makeCached := func(i *identity.Identity, entityUpdated func(id entity.Id) error) *IdentityCache { + return NewIdentityCache(i, repo, entityUpdated) + } + + makeExcerpt := func(i *identity.Identity) *IdentityExcerpt { + return NewIdentityExcerpt(i) + } + + makeIndex := func(i *IdentityCache) []string { + // no indexing + return nil + } + + sc := NewSubCache[*identity.Identity, *IdentityExcerpt, *IdentityCache]( + repo, resolvers, getUserIdentity, + makeCached, makeExcerpt, makeIndex, + "identity", "identities", + formatVersion, defaultMaxLoadedBugs, + ) + + return &RepoCacheIdentity{SubCache: sc} } // ResolveIdentityImmutableMetadata retrieve an Identity that has the exact given metadata on @@ -65,7 +94,7 @@ func (c *RepoCacheIdentity) finishIdentity(i *identity.Identity, metadata map[st return nil, fmt.Errorf("identity %s already exist in the cache", i.Id()) } - cached := NewIdentityCache(c, i) + cached := NewIdentityCache(i, c.repo, c.entityUpdated) c.cached[i.Id()] = cached c.mu.Unlock() |