Table of Contents

NotableDateCacheOptions Class

Definition

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

Provides the storage-agnostic options shared by every INotableDateCache. Storage-specific option types derive from this base to add their own location settings.

public class NotableDateCacheOptions
Inheritance
NotableDateCacheOptions
Derived
Inherited Members
Extension Methods

Remarks

Unlike the exchange-rate cache, a notable-date cache is not bound to a single provider: it keys entries by territory, year, and resource version, so one instance serves every territory a service resolves.

Constructors

NotableDateCacheOptions()

public NotableDateCacheOptions()

Properties

ThrowOnStorageFailure

Gets or sets a value indicating whether a storage read or write failure is surfaced as an exception rather than degrading to an empty read or a skipped write.

public bool ThrowOnStorageFailure { get; set; }

Property Value

bool

true to rethrow the underlying storage failure; false (the default) to keep the best-effort behaviour the INotableDateCache contract describes.

Remarks

The default keeps a cache fault from breaking notable-date resolution, which suits most consumers. Set it for a deployment that must not run with a silently broken cache. Argument validation always throws regardless of this setting.

The failure is rethrown as the store produced it rather than being translated, so a caller handles the pair the cache treats as a storage failure: IOException and UnauthorizedAccessException. Which of the two a given fault yields is the storage layer's choice and varies by platform - a blocked file write surfaces as IOException on Unix and UnauthorizedAccessException on Windows - so code that catches only one will miss the other.

ValidateStorageOnStart

Gets or sets a value indicating whether the cache eagerly probes its backing store when constructed and throws when the store is unusable, rather than deferring the discovery to the first read or write.

public bool ValidateStorageOnStart { get; set; }

Property Value

bool

true to probe the store at construction; false (the default) to skip the probe.

Remarks

The SQLite and distributed dependency-injection packages run this probe through their ValidateOnStart wiring, so a misconfigured store fails the host start; a cache constructed directly probes in its constructor instead. This setting is independent of ThrowOnStorageFailure.

Methods

TryValidate(out string?)

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

public virtual 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 virtual void Validate()

Remarks

The base has no invariants to enforce; storage-specific option types override this method to add their own. The throwing form preserves the ParamName of the offending option; the dependency-injection registration instead wires TryValidate(out string?) into ValidateOnStart.

Applies to

ProductVersions
.NET8, 10