/// <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); }
/// <inheritdoc cref="ISyncCachedQuery{TCacheEntryOptions}.EvictCachedResult"/> public virtual void EvictCachedResult(ISyncCacheStore <TCacheEntryOptions> cacheStore) { if (cacheStore == null) { throw new ArgumentNullException(nameof(cacheStore)); } cacheStore.RemoveEntry(State.CacheKey); }
/// <inheritdoc cref="ISyncCachedQuery{TContext,TCacheEntryOptions,TResult}.Execute"/> public virtual TTransformedResult Execute(TContext context, ISyncCacheStore <TCacheEntryOptions> cacheStore, CacheOption cacheOption) { var cachedResult = GetCachedResult(context, cacheStore, cacheOption); return(TransformCachedResult(cachedResult)); }
/// <inheritdoc cref="ISyncCachedQuery{TContext,TCacheEntryOptions,TResult}.Execute"/> public virtual TResult Execute(TContext context, ISyncCacheStore <TCacheEntryOptions> cacheStore, CacheOption cacheOption) => GetCachedResult(context, cacheStore, cacheOption);