public async Task Should_get_app_with_schema_from_index() { var schema = Mocks.Schema(app.NamedId(), schemaId); A.CallTo(() => indexForApps.GetAppAsync(app.Id, false, ct)) .Returns(app); A.CallTo(() => indexForSchemas.GetSchemaAsync(app.Id, schema.Id, false, ct)) .Returns(schema); var result = await sut.GetAppWithSchemaAsync(app.Id, schemaId.Id, false, ct); Assert.Equal(schema, result.Item2); }
public Task <ISchemaEntity?> GetSchemaAsync(DomainId appId, DomainId id, bool allowDeleted = false) { return(localCache.GetOrCreateAsync($"GetSchemaAsync({appId}, {id}, {allowDeleted})", async() => { return await indexSchemas.GetSchemaAsync(appId, id, allowDeleted); })); }
public async Task <ISchemaEntity?> GetSchemaAsync(DomainId appId, string name, bool canCache = false, CancellationToken ct = default) { var cacheKey = SchemaCacheKey(appId, name); var schema = await GetOrCreate(cacheKey, () => { return(indexForSchemas.GetSchemaAsync(appId, name, canCache, ct)); }); if (schema != null) { localCache.Add(SchemaCacheKey(appId, schema.Id), schema); } return(schema); }
public async Task <ISchemaEntity?> GetSchemaAsync(DomainId appId, string name, bool canCache = false, CancellationToken ct = default) { var cacheKey = SchemaCacheKey(appId, name); if (localCache.TryGetValue(cacheKey, out var cached) && cached is ISchemaEntity found) { return(found); } var schema = await indexForSchemas.GetSchemaAsync(appId, name, canCache, ct); if (schema != null) { localCache.Add(cacheKey, schema); localCache.Add(SchemaCacheKey(appId, schema.Id), schema); } return(schema); }
public async Task <ISchemaEntity?> GetSchemaAsync(DomainId appId, DomainId id, bool allowDeleted = false, bool canCache = false) { var schema = await localCache.GetOrCreateAsync(SchemaCacheKey(appId, id), () => { return(indexSchemas.GetSchemaAsync(appId, id, canCache)); }); if (schema != null) { localCache.Add(SchemaCacheKey(appId, schema.Id), schema); } return(schema?.IsDeleted == true && !allowDeleted ? null : schema); }
public async Task <ISchemaEntity?> GetSchemaAsync(DomainId appId, DomainId id, bool canCache = false) { var cacheKey = SchemaCacheKey(appId, id); if (localCache.TryGetValue(cacheKey, out var cached) && cached is ISchemaEntity found) { return(found); } var schema = await indexSchemas.GetSchemaAsync(appId, id, canCache); if (schema != null) { localCache.Add(cacheKey, schema); localCache.Add(SchemaCacheKey(appId, schema.SchemaDef.Name), schema); } return(schema); }