Class HybridCacheQueryBehavior<TRequest, TResponse>
- Namespace
- Arbiter.CommandQuery.Behaviors
- Assembly
- Arbiter.CommandQuery.dll
A behavior for caching the response of a query to HybridCache.
TRequest
must implement ICacheResult for the response to be cached.
public class HybridCacheQueryBehavior<TRequest, TResponse> : PipelineBehaviorBase<TRequest, TResponse>, IPipelineBehavior<TRequest, TResponse> where TRequest : class, IRequest<TResponse>
Type Parameters
TRequest
The type of the request.
TResponse
The type of the response.
- Inheritance
-
PipelineBehaviorBase<TRequest, TResponse>HybridCacheQueryBehavior<TRequest, TResponse>
- Implements
-
IPipelineBehavior<TRequest, TResponse>
- Inherited Members
Constructors
HybridCacheQueryBehavior(ILoggerFactory, HybridCache)
Initializes a new instance of the HybridCacheQueryBehavior<TRequest, TResponse> class.
public HybridCacheQueryBehavior(ILoggerFactory loggerFactory, HybridCache hybridCache)
Parameters
loggerFactory
ILoggerFactoryThe logger factory to create an ILogger from
hybridCache
HybridCacheThe hybrid cache.
Exceptions
- ArgumentNullException
hybridCache
Methods
Process(TRequest, RequestHandlerDelegate<TResponse>, CancellationToken)
Processes the specified request with the additional behavior.
protected override ValueTask<TResponse?> Process(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken)
Parameters
request
TRequestThe incoming request.
next
RequestHandlerDelegate<TResponse>Awaitable delegate for the next action in the pipeline. Eventually this delegate represents the handler.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- ValueTask<TResponse>
Awaitable task returning the
TResponse