Table of Contents

Class MemoryCacheQueryBehavior<TRequest, TResponse>

Namespace
Arbiter.CommandQuery.Behaviors
Assembly
Arbiter.CommandQuery.dll

A behavior for caching the response of a query to IMemoryCache. TRequest must implement ICacheResult for the response to be cached.

public class MemoryCacheQueryBehavior<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>
MemoryCacheQueryBehavior<TRequest, TResponse>
Implements
IPipelineBehavior<TRequest, TResponse>
Inherited Members

Constructors

MemoryCacheQueryBehavior(ILoggerFactory, IMemoryCache)

Initializes a new instance of the MemoryCacheQueryBehavior<TRequest, TResponse> class.

public MemoryCacheQueryBehavior(ILoggerFactory loggerFactory, IMemoryCache memoryCache)

Parameters

loggerFactory ILoggerFactory
memoryCache IMemoryCache

Exceptions

ArgumentNullException

When memoryCache is null

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 TRequest

The incoming request.

next RequestHandlerDelegate<TResponse>

Awaitable delegate for the next action in the pipeline. Eventually this delegate represents the handler.

cancellationToken CancellationToken

The cancellation token.

Returns

ValueTask<TResponse>

Awaitable task returning the TResponse