FileSystemRbaWorkbookCache Class
Definition
- Namespace
- Bodu.Financial.ExchangeRates
- Assembly
- Bodu.Financial.ExchangeRates.Rba.dll
- Package
- Bodu.Financial.ExchangeRates.Rba 0.7.1
An IByteCache<TKey> that persists downloaded RBA workbooks as files in a cache directory, keyed by the era workbook that produced them.
public sealed class FileSystemRbaWorkbookCache : FileSystemByteCache<RbaEraWorkbook>, IByteCache<RbaEraWorkbook>
- Inheritance
-
FileSystemRbaWorkbookCache
- Implements
- Inherited Members
- Extension Methods
Remarks
Each era is stored under its file name in the cache directory; the file's last-write time serves as the freshness timestamp. Immutable eras are served from the cache regardless of age, while the open-ended current era is treated as stale once it exceeds the supplied refresh interval, forcing a re-download.
The cache is best-effort: any I/O failure while reading is reported as a miss, and any failure while writing is swallowed, so a cache problem never breaks rate retrieval.
Constructors
FileSystemRbaWorkbookCache(string?, ILogger?)
Initializes a new instance of the FileSystemRbaWorkbookCache class.
public FileSystemRbaWorkbookCache(string? directory, ILogger? logger = null)
Parameters
Methods
GetFileName(RbaEraWorkbook)
Derives the cache file name for a key.
protected override string GetFileName(RbaEraWorkbook key)
Parameters
keyRbaEraWorkbookThe download unit to name.
Returns
- string
The cache file name.
Exceptions
- ArgumentNullException
keyis null.
IsFresh(RbaEraWorkbook, TimeSpan, TimeSpan)
Determines whether a cached file of the supplied age is still fresh for a key.
protected override bool IsFresh(RbaEraWorkbook key, TimeSpan age, TimeSpan refreshInterval)
Parameters
keyRbaEraWorkbookThe download unit the file was cached for.
ageTimeSpanThe elapsed time since the file was last written.
refreshIntervalTimeSpanThe maximum age a cached file may reach before it is treated as stale.
Returns
- bool
true when the file may still be served; otherwise false. The default treats a file as fresh while its age does not exceed
refreshInterval.
Remarks
The open-ended current era expires on the refresh interval; fixed eras are immutable and never expire.
Exceptions
- ArgumentNullException
keyis null.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |