Table of Contents

Class CacheableQueryBase<TResponse>

Namespace
Arbiter.CommandQuery.Queries
Assembly
Arbiter.CommandQuery.dll

Represents a base class for cacheable queries that use a specified ClaimsPrincipal for user context.

public abstract record CacheableQueryBase<TResponse> : PrincipalQueryBase<TResponse>, IRequest<TResponse>, IRequest, IEquatable<PrincipalCommandBase<TResponse>>, IEquatable<PrincipalQueryBase<TResponse>>, ICacheResult, IEquatable<CacheableQueryBase<TResponse>>

Type Parameters

TResponse

The type of the response returned by the query.

Inheritance
CacheableQueryBase<TResponse>
Implements
IRequest<TResponse>
Derived
Inherited Members

Remarks

This class provides support for cache key generation, cache tagging, and cache expiration policies. It is intended for use in scenarios where query results can be cached and associated with a user principal.

Constructors

CacheableQueryBase(ClaimsPrincipal?)

Initializes a new instance of the CacheableQueryBase<TResponse> class.

protected CacheableQueryBase(ClaimsPrincipal? principal)

Parameters

principal ClaimsPrincipal

The ClaimsPrincipal representing the user for whom the query is executed.

Methods

Cache(DateTimeOffset?)

Sets the absolute expiration for the cache entry associated with this query.

public void Cache(DateTimeOffset? absoluteExpiration)

Parameters

absoluteExpiration DateTimeOffset?

The absolute expiration date and time, or null to unset.

Cache(TimeSpan?)

Sets the sliding expiration for the cache entry associated with this query.

public void Cache(TimeSpan? expiration)

Parameters

expiration TimeSpan?

The sliding expiration time span, or null to unset.

GetCacheKey()

Gets the cache key for this query instance.

public abstract string GetCacheKey()

Returns

string

A string representing the cache key.

GetCacheTag()

Gets the cache tag for this query instance.

public virtual string? GetCacheTag()

Returns

string

A string representing the cache tag, or null if not set.

IsCacheable()

Determines whether this query is cacheable based on the expiration settings.

public bool IsCacheable()

Returns

bool

true if either absolute or sliding expiration is set; otherwise, false.