diff --git a/src/OrchardCore/OrchardCore.Infrastructure/Documents/DocumentManager.cs b/src/OrchardCore/OrchardCore.Infrastructure/Documents/DocumentManager.cs index cf1162aea17..6751cf322ab 100644 --- a/src/OrchardCore/OrchardCore.Infrastructure/Documents/DocumentManager.cs +++ b/src/OrchardCore/OrchardCore.Infrastructure/Documents/DocumentManager.cs @@ -364,23 +364,20 @@ protected async Task InvalidateInternalAsync(TDocument document, bool failover = private async Task GetFromDistributedCacheAsync() { - byte[] data = null; - if (_isDistributed) { - data = await _distributedCache.GetAsync(_options.CacheKey); + byte[] data = await _distributedCache.GetAsync(_options.CacheKey); + if (data == null) + { + return null; + } + return await _options.Serializer.DeserializeAsync(data); } else if (_memoryCache.TryGetValue(_options.CacheKey, out var cached)) { - data = await _options.Serializer.SerializeAsync(cached); - } - - if (data == null) - { - return null; + return cached; } - - return await _options.Serializer.DeserializeAsync(data); + return null; } private async Task UpdateDistributedCacheAsync(TDocument document)