public override async Task <TEntity> New(Id id)
        {
            var cacheId = $"{_parent.Bucket}.{_parent.Id}.{id}";

            if (!Tracked.TryGetValue(cacheId, out var root))
            {
                root = await NewUnTracked(_parent.Bucket, id, _parent).ConfigureAwait(false);

                if (!Tracked.TryAdd(cacheId, root))
                {
                    throw new InvalidOperationException($"Could not add cache key [{cacheId}] to repo tracked");
                }
            }

            return(root);
        }
Exemple #2
0
        public override async Task <TEntity> Get(Id id)
        {
            var     cacheId = $"{_parent.Bucket}.{_parent.BuildParentsString()}.{id}";
            TEntity root;

            if (!Tracked.TryGetValue(cacheId, out root))
            {
                root = await GetUntracked(_parent.Bucket, id, _parent.BuildParents()).ConfigureAwait(false);

                if (!Tracked.TryAdd(cacheId, root))
                {
                    throw new InvalidOperationException($"Could not add cache key [{cacheId}] to repo tracked");
                }
            }

            return(root);
        }