Table of Contents

DistributedNotableDateCacheOptions Class

Definition

Namespace
Bodu.Globalization.Calendar.Caching
Assembly
Bodu.Globalization.Calendar.Caching.Distributed.dll
Package
Bodu.Globalization.Calendar.Caching.Distributed 1.0.0
Source
DistributedNotableDateCacheOptions.cs

Configures a distributed INotableDateCache: the optional key prefix its per-territory blobs are namespaced under. The backing store itself is supplied through dependency injection as an IDistributedCache.

public class DistributedNotableDateCacheOptions : NotableDateCacheOptions
Inheritance
DistributedNotableDateCacheOptions
Inherited Members
Extension Methods

Constructors

DistributedNotableDateCacheOptions()

public DistributedNotableDateCacheOptions()

Properties

EntryExpirationMargin

Gets or sets the margin added to the time-to-live when deriving each written territory blob's server-side absolute expiration, or null to write entries without any server-side expiration.

public TimeSpan? EntryExpirationMargin { get; set; }

Property Value

TimeSpan?

The expiration margin; defaults to one hour.

Remarks

Every entry this cache serves must already be fresh under the per-call time-to-live, so a blob evicted server-side at ttl + margin would in any case have been filtered on read - served results are unchanged in any normal configuration, while a territory that stops being queried self-evicts from the backing store instead of lingering forever. A deployment that stores under one time-to-live and later reads under a longer one could observe a server-side eviction where it previously saw a hit; set the margin to null to opt out and restore unbounded server-side lifetime.

KeyPrefix

Gets or sets the prefix prepended to every cache key, so several logical caches can share one distributed store without colliding.

public string? KeyPrefix { get; set; }

Property Value

string

The key prefix, or null for no prefix.

Methods

TryValidate(out string?)

Attempts to validate the options without throwing, reporting the first invariant that is violated.

public override bool TryValidate(out string? error)

Parameters

error string

When this method returns false, a message describing the first violated invariant; otherwise null.

Returns

bool

true when every invariant holds; otherwise false.

Remarks

The dependency-injection registration wires this method into ValidateOnStart so misconfiguration fails fast at application startup. Storage-specific option types override this method to add their own invariants after invoking the base implementation.

Validate()

Validates the option values, throwing when a rule is violated.

public override void Validate()

Exceptions

ArgumentException

Thrown when KeyPrefix is white space, or when EntryExpirationMargin is negative.

Applies to

ProductVersions
.NET8, 10