/// <inheritdoc cref="ISyncCachedQuery{TContext,TCacheEntryOptions,TResult}.Execute"/> protected virtual TCachedResult GetCachedResult(TContext context, ISyncCacheStore <TCacheEntryOptions> cacheStore, CacheOption cacheOption) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (cacheStore == null) { throw new ArgumentNullException(nameof(cacheStore)); } State.SetContext(context); if (cacheOption == CacheOption.Default) { var cacheEntry = cacheStore.GetEntry <TCachedResult>(State.CacheKey); if (cacheEntry != null) { return(State.SetCachedResult(cacheEntry.Value)); } } var result = Query(context); cacheStore.SetEntry(State.CacheKey, result.ToCacheEntry(), State.CacheEntryOptions); return(State.SetCachedResult(result)); }
/// <inheritdoc cref="ISyncCachedQuery{TCacheEntryOptions}.UpdateCachedResult"/> public virtual void UpdateCachedResult(ISyncCacheStore <TCacheEntryOptions> cacheStore) { if (cacheStore == null) { throw new ArgumentNullException(nameof(cacheStore)); } cacheStore.SetEntry(State.CacheKey, State.CachedResult.ToCacheEntry(), State.CacheEntryOptions); }