public virtual async Task <IResultList <IEnrichedAssetEntity> > QueryAssetsAsync(Q q, CancellationToken ct) { IResultList <IEnrichedAssetEntity> assets; await maxRequests.WaitAsync(ct); try { assets = await AssetQuery.QueryAsync(Context, null, q, ct); } finally { maxRequests.Release(); } AssetCache.SetMany(assets.Select(x => (x.Id, x)) !); return(assets); }
public virtual async Task <IReadOnlyList <IEnrichedAssetEntity> > GetReferencedAssetsAsync(IEnumerable <DomainId> ids, CancellationToken ct) { Guard.NotNull(ids); return(await AssetCache.CacheOrQueryAsync(ids, async pendingIds => { await maxRequests.WaitAsync(ct); try { var q = Q.Empty.WithIds(pendingIds).WithoutTotal(); return await AssetQuery.QueryAsync(Context, null, q, ct); } finally { maxRequests.Release(); } })); }