NotableDateCacheOptions Class
Definition
- Namespace
- Bodu.Globalization.Calendar.Caching
- Assembly
- Bodu.Globalization.Calendar.Caching.dll
- Package
- Bodu.Globalization.Calendar.Caching 1.3.0
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 behavior 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
exceptions its backend treats as storage failures: IOException and
UnauthorizedAccessException for the file caches, SqliteException and
IOException for the SQLite cache, and any exception other than
OperationCanceledException for the distributed cache. For the file caches, 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 backing store is probed eagerly, and an unusable store throws, rather than deferring the discovery to the first read or write.
public bool ValidateStorageOnStart { get; set; }
Property Value
Remarks
The file and SQLite caches probe in their constructors, and the SQLite and distributed dependency-injection
registrations run the probe through their ValidateOnStart wiring, so a misconfigured store fails the host
start. The distributed cache's constructor does not probe, so a distributed cache constructed directly is never
probed. 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
errorstringWhen this method returns false, a message describing the first violated invariant; otherwise null.
Returns
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
| Product | Versions |
|---|---|
| .NET | 8, 10 |