Browse Source

Disable document resource cache on development

pull/2297/head
Halil İbrahim Kalkan 7 years ago
parent
commit
76d32f8af2
  1. 14
      modules/docs/src/Volo.Docs.Application/Volo/Docs/Documents/DocumentAppService.cs

14
modules/docs/src/Volo.Docs.Application/Volo/Docs/Documents/DocumentAppService.cs

@ -1,11 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.Caching.Distributed; using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Volo.Abp.Application.Services;
using Volo.Abp.Caching; using Volo.Abp.Caching;
using Volo.Docs.Projects; using Volo.Docs.Projects;
@ -18,19 +16,21 @@ namespace Volo.Docs.Documents
protected IDistributedCache<DocumentWithDetailsDto> DocumentCache { get; } protected IDistributedCache<DocumentWithDetailsDto> DocumentCache { get; }
protected IDistributedCache<LanguageConfig> LanguageCache { get; } protected IDistributedCache<LanguageConfig> LanguageCache { get; }
protected IDistributedCache<DocumentResourceDto> ResourceCache { get; } protected IDistributedCache<DocumentResourceDto> ResourceCache { get; }
protected IHostEnvironment HostEnvironment { get; }
public DocumentAppService( public DocumentAppService(
IProjectRepository projectRepository, IProjectRepository projectRepository,
IDocumentStoreFactory documentStoreFactory, IDocumentStoreFactory documentStoreFactory,
IDistributedCache<DocumentWithDetailsDto> documentCache, IDistributedCache<DocumentWithDetailsDto> documentCache,
IDistributedCache<LanguageConfig> languageCache, IDistributedCache<LanguageConfig> languageCache,
IDistributedCache<DocumentResourceDto> resourceCache) IDistributedCache<DocumentResourceDto> resourceCache,
IHostEnvironment hostEnvironment)
{ {
_projectRepository = projectRepository; _projectRepository = projectRepository;
_documentStoreFactory = documentStoreFactory; _documentStoreFactory = documentStoreFactory;
DocumentCache = documentCache; DocumentCache = documentCache;
LanguageCache = languageCache; LanguageCache = languageCache;
ResourceCache = resourceCache; ResourceCache = resourceCache;
HostEnvironment = hostEnvironment;
} }
public virtual async Task<DocumentWithDetailsDto> GetAsync(GetDocumentInput input) public virtual async Task<DocumentWithDetailsDto> GetAsync(GetDocumentInput input)
@ -83,7 +83,7 @@ namespace Volo.Docs.Documents
return ObjectMapper.Map<DocumentResource, DocumentResourceDto>(documentResource); return ObjectMapper.Map<DocumentResource, DocumentResourceDto>(documentResource);
} }
if (Debugger.IsAttached) if (HostEnvironment.IsDevelopment())
{ {
return await GetResourceAsync(); return await GetResourceAsync();
} }
@ -119,7 +119,7 @@ namespace Volo.Docs.Documents
return CreateDocumentWithDetailsDto(project, document); return CreateDocumentWithDetailsDto(project, document);
} }
if (Debugger.IsAttached) if (HostEnvironment.IsDevelopment())
{ {
return await GetDocumentAsync(); return await GetDocumentAsync();
} }

Loading…
Cancel
Save