IImfReportCache Interface
Definition
- Namespace
- Bodu.Financial.ExchangeRates
- Assembly
- Bodu.Financial.ExchangeRates.Imf.dll
- Package
- Bodu.Financial.ExchangeRates.Imf 0.7.2
- Source
- IImfReportCache.cs
Caches the raw bytes of downloaded IMF monthly report files so they need not be re-fetched on every load.
public interface IImfReportCache
- Extension Methods
Remarks
A report for a closed month is immutable, so an entry cached after its month closed is always fresh; an entry cached while its month was still accumulating business days is treated as stale once it is older than a caller-supplied refresh interval, even after the month has closed. Implementations are expected to be resilient: a cache failure should manifest as a miss rather than an exception that breaks rate retrieval.
Methods
Store(ImfReportMonth, byte[])
Stores the bytes for a report month, replacing any existing entry.
void Store(ImfReportMonth month, byte[] bytes)
Parameters
monthImfReportMonthThe report month whose file is being cached.
bytesbyte[]The report bytes to store.
TryGet(ImfReportMonth, TimeSpan, out byte[])
Attempts to retrieve the cached bytes for a report month.
bool TryGet(ImfReportMonth month, TimeSpan refreshInterval, out byte[] bytes)
Parameters
monthImfReportMonthThe report month whose file is requested.
refreshIntervalTimeSpanThe maximum age at which a current-month report is still considered fresh.
bytesbyte[]When this method returns true, the cached report bytes; otherwise null.
Returns
TryGet(ImfReportMonth, TimeSpan, out byte[], out DateTimeOffset?)
Attempts to retrieve the cached bytes for a report month, together with the instant they were stored.
bool TryGet(ImfReportMonth month, TimeSpan refreshInterval, out byte[] bytes, out DateTimeOffset? storedAtUtc)
Parameters
monthImfReportMonthThe report month whose file is requested.
refreshIntervalTimeSpanThe maximum age at which a current-month report is still considered fresh.
bytesbyte[]When this method returns true, the cached report bytes; otherwise null.
storedAtUtcDateTimeOffset?When this method returns true, the instant the entry was stored, or null when the cache does not record it; otherwise null.
Returns
Remarks
The provider stamps a month served from the cache with storedAtUtc, the time its bytes were
fetched from the IMF, rather than the time they were read back. The default implementation calls
TryGet(ImfReportMonth, TimeSpan, out byte[]) and reports no stored time.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |