Browse Source

Caching fixes.

pull/107/head
Sebastian Stehle 9 years ago
parent
commit
df54494f62
  1. 3
      src/Squidex.Domain.Apps.Read/Contents/GraphQL/CachingGraphQLService.cs
  2. 22
      src/Squidex.Domain.Apps.Read/Schemas/Services/Implementations/CachingSchemaProvider.cs

3
src/Squidex.Domain.Apps.Read/Contents/GraphQL/CachingGraphQLService.cs

@ -29,6 +29,7 @@ namespace Squidex.Domain.Apps.Read.Contents.GraphQL
{
public sealed class CachingGraphQLService : CachingProviderBase, IGraphQLService, IEventConsumer
{
private static readonly TimeSpan CacheDuration = TimeSpan.FromMinutes(60);
private readonly IContentRepository contentRepository;
private readonly IGraphQLUrlGenerator urlGenerator;
private readonly IAssetRepository assetRepository;
@ -108,7 +109,7 @@ namespace Squidex.Domain.Apps.Read.Contents.GraphQL
modelContext = new GraphQLModel(app, allSchemas.Where(x => x.IsPublished), urlGenerator);
Cache.Set(cacheKey, modelContext);
Cache.Set(cacheKey, modelContext, CacheDuration);
}
return modelContext;

22
src/Squidex.Domain.Apps.Read/Schemas/Services/Implementations/CachingSchemaProvider.cs

@ -9,7 +9,7 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Caching.Memory;
using Squidex.Domain.Apps.Events.Schemas;
using Squidex.Domain.Apps.Events;
using Squidex.Domain.Apps.Read.Schemas.Repositories;
using Squidex.Domain.Apps.Read.Utils;
using Squidex.Infrastructure;
@ -110,25 +110,9 @@ namespace Squidex.Domain.Apps.Read.Schemas.Services.Implementations
Cache.Invalidate(cacheKeyByName);
}
if (@event.Payload is FieldEvent fieldEvent)
if (@event.Payload is SchemaEvent schemaEvent)
{
Remove(fieldEvent.AppId, fieldEvent.SchemaId);
}
else if (@event.Payload is SchemaCreated schemaCreatedEvent)
{
Remove(schemaCreatedEvent.AppId, schemaCreatedEvent.SchemaId);
}
else if (@event.Payload is SchemaDeleted schemaDeletedEvent)
{
Remove(schemaDeletedEvent.AppId, schemaDeletedEvent.SchemaId);
}
else if (@event.Payload is SchemaUpdated schemaUpdatedEvent)
{
Remove(schemaUpdatedEvent.AppId, schemaUpdatedEvent.SchemaId);
}
else if (@event.Payload is ScriptsConfigured scriptsConfiguredEvent)
{
Remove(scriptsConfiguredEvent.AppId, scriptsConfiguredEvent.SchemaId);
Remove(schemaEvent.AppId, schemaEvent.SchemaId);
}
return TaskHelper.Done;

Loading…
Cancel
Save