public virtual async Task <IResultList <IEnrichedContentEntity> > QueryContentsAsync(string schemaIdOrName, Q q, CancellationToken ct) { IResultList <IEnrichedContentEntity> contents; await maxRequests.WaitAsync(ct); try { contents = await ContentQuery.QueryAsync(Context, schemaIdOrName, q, ct); } finally { maxRequests.Release(); } ContentCache.SetMany(contents.Select(x => (x.Id, x)) !); return(contents); }
public virtual async Task <IReadOnlyList <IEnrichedContentEntity> > GetReferencedContentsAsync(IEnumerable <DomainId> ids, CancellationToken ct) { Guard.NotNull(ids); return(await ContentCache.CacheOrQueryAsync(ids, async pendingIds => { await maxRequests.WaitAsync(ct); try { var q = Q.Empty.WithIds(pendingIds).WithoutTotal(); return await ContentQuery.QueryAsync(Context, q, ct); } finally { maxRequests.Release(); } })); }