Skip to content

Commit

Permalink
reverted count to be a prefixed cache key
Browse files Browse the repository at this point in the history
  • Loading branch information
niemyjski committed Mar 24, 2016
1 parent 5b9c822 commit 8057390
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected async Task<long> CountAsync(object query) {
if (query == null)
throw new ArgumentNullException(nameof(query));

var result = IsCacheEnabled ? await GetCachedQueryResultAsync<long?>(query, cacheSuffix: "count").AnyContext() : null;
var result = IsCacheEnabled ? await GetCachedQueryResultAsync<long?>(query, "count").AnyContext() : null;
if (result != null)
return result.Value;

Expand All @@ -169,7 +169,7 @@ protected async Task<long> 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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Elasticsearch/Tests/Repositories/EmployeeRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected override async Task InvalidateCacheAsync(ICollection<ModifiedDocument<

var options = Options as IQueryOptions;
if (documents != null && documents.Count > 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);
Expand Down

0 comments on commit 8057390

Please sign in to comment.