From 8057390672edddd8a046d127d7674ec763bda1cc Mon Sep 17 00:00:00 2001 From: Blake Niemyjski Date: Thu, 24 Mar 2016 17:50:29 -0500 Subject: [PATCH] reverted count to be a prefixed cache key --- .../Repositories/ElasticReadOnlyRepositoryBase.cs | 4 ++-- src/Elasticsearch/Tests/Repositories/EmployeeRepository.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Elasticsearch/Repositories/ElasticReadOnlyRepositoryBase.cs b/src/Elasticsearch/Repositories/ElasticReadOnlyRepositoryBase.cs index ed6ccfb6..39f18dba 100644 --- a/src/Elasticsearch/Repositories/ElasticReadOnlyRepositoryBase.cs +++ b/src/Elasticsearch/Repositories/ElasticReadOnlyRepositoryBase.cs @@ -154,7 +154,7 @@ protected async Task CountAsync(object query) { if (query == null) throw new ArgumentNullException(nameof(query)); - var result = IsCacheEnabled ? await GetCachedQueryResultAsync(query, cacheSuffix: "count").AnyContext() : null; + var result = IsCacheEnabled ? await GetCachedQueryResultAsync(query, "count").AnyContext() : null; if (result != null) return result.Value; @@ -169,7 +169,7 @@ protected async Task CountAsync(object query) { throw new ApplicationException($"ElasticSearch error code \"{results.ConnectionStatus.HttpStatusCode}\".", results.ConnectionStatus.OriginalException); if (IsCacheEnabled) - await SetCachedQueryResultAsync(query, results.Count, cacheSuffix: "count").AnyContext(); + await SetCachedQueryResultAsync(query, results.Count, "count").AnyContext(); return results.Count; } diff --git a/src/Elasticsearch/Tests/Repositories/EmployeeRepository.cs b/src/Elasticsearch/Tests/Repositories/EmployeeRepository.cs index 9dbd30b1..4fed7c60 100644 --- a/src/Elasticsearch/Tests/Repositories/EmployeeRepository.cs +++ b/src/Elasticsearch/Tests/Repositories/EmployeeRepository.cs @@ -39,7 +39,7 @@ protected override async Task InvalidateCacheAsync(ICollection 0 && options != null && options.HasIdentity) { - var keys = documents.Select(d => $"{d.Value.CompanyId}:count").Distinct().ToList(); + var keys = documents.Select(d => $"count:{d.Value.CompanyId}").Distinct().ToList(); if (keys.Count > 0) await Cache.RemoveAllAsync(keys);