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
-
PrincipalCommandBase<TResponse>PrincipalQueryBase<TResponse>CacheableQueryBase<TResponse>
- Implements
-
IRequest<TResponse>IEquatable<PrincipalCommandBase<TResponse>>IEquatable<PrincipalQueryBase<TResponse>>IEquatable<CacheableQueryBase<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
ClaimsPrincipalThe 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
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
IsCacheable()
Determines whether this query is cacheable based on the expiration settings.
public bool IsCacheable()