aboutsummaryrefslogtreecommitdiffstats
path: root/cache/identity_cache.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2022-11-19 11:33:12 +0100
committerMichael Muré <batolettre@gmail.com>2022-11-28 17:20:25 +0100
commit0ac39a7ab5db077fcf0df827e32bf6e625e980da (patch)
treee453d6fd244cb322bdc6305c0088aa3c0331b075 /cache/identity_cache.go
parentc6bb6b9c7ecddb679966b1561e2e909a9ee5e8cd (diff)
downloadgit-bug-0ac39a7ab5db077fcf0df827e32bf6e625e980da.tar.gz
WIP
Diffstat (limited to 'cache/identity_cache.go')
-rw-r--r--cache/identity_cache.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/cache/identity_cache.go b/cache/identity_cache.go
index 3b7bb818..a6c929ad 100644
--- a/cache/identity_cache.go
+++ b/cache/identity_cache.go
@@ -2,6 +2,7 @@ package cache
import (
"github.com/MichaelMure/git-bug/entities/identity"
+ "github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/repository"
)
@@ -9,19 +10,22 @@ var _ identity.Interface = &IdentityCache{}
// IdentityCache is a wrapper around an Identity for caching.
type IdentityCache struct {
+ entityUpdated func(id entity.Id) error
+ repo repository.ClockedRepo
+
*identity.Identity
- repoCache *RepoCache
}
-func NewIdentityCache(repoCache *RepoCache, id *identity.Identity) *IdentityCache {
+func NewIdentityCache(subcache *RepoCacheIdentity, id *identity.Identity) *IdentityCache {
return &IdentityCache{
- Identity: id,
- repoCache: repoCache,
+ entityUpdated: subcache.entityUpdated,
+ repo: subcache.repo,
+ Identity: id,
}
}
func (i *IdentityCache) notifyUpdated() error {
- return i.repoCache.identityUpdated(i.Identity.Id())
+ return i.entityUpdated(i.Identity.Id())
}
func (i *IdentityCache) Mutate(repo repository.RepoClock, f func(*identity.Mutator)) error {
@@ -33,7 +37,7 @@ func (i *IdentityCache) Mutate(repo repository.RepoClock, f func(*identity.Mutat
}
func (i *IdentityCache) Commit() error {
- err := i.Identity.Commit(i.repoCache.repo)
+ err := i.Identity.Commit(i.repo)
if err != nil {
return err
}
@@ -41,7 +45,7 @@ func (i *IdentityCache) Commit() error {
}
func (i *IdentityCache) CommitAsNeeded() error {
- err := i.Identity.CommitAsNeeded(i.repoCache.repo)
+ err := i.Identity.CommitAsNeeded(i.repo)
if err != nil {
return err
}