InMemoryHttpCacheStore Class
Stores HTTP cache entries in-memory and can persist them to a JSON file.
public sealed class InMemoryHttpCacheStore : IHttpCacheStore- Implements
Constructors
| Name | Description |
|---|---|
| InMemoryHttpCacheStore() |
InMemoryHttpCacheStore()
InMemoryHttpCacheStore.cspublic InMemoryHttpCacheStore()No documentation is available.
Methods
| Name | Description |
|---|---|
| GetEntriesAsync(string, CancellationToken) | Gets all entries associated with a primary cache key. |
| LoadFromFileAsync(string, CancellationToken) | Loads cache entries from a JSON file and replaces current in-memory entries. |
| PruneObsoleteEntriesAsync(DateTimeOffset, CancellationToken) | Removes expired entries that cannot be reused when stale. |
| PruneObsoleteEntriesAsync(CancellationToken) | Removes expired entries that cannot be reused when stale. |
| RemoveEntriesAsync(string, CancellationToken) | Removes all entries associated with a primary cache key. |
| SaveToFileAsync(string, CancellationToken) | Saves all in-memory cache entries to a JSON file. |
| SetEntryAsync(string, HttpCachePersistenceEntry, CancellationToken) | Adds or replaces a cache entry for a primary key. |
GetEntriesAsync(string, CancellationToken)
InMemoryHttpCacheStore.csGets all entries associated with a primary cache key.
public ValueTask<IReadOnlyCollection<HttpCachePersistenceEntry>> GetEntriesAsync(string primaryKey, CancellationToken cancellationToken)Parameters
primaryKeystring- The primary cache key.
cancellationTokenCancellationToken- The cancellation token.
Returns
LoadFromFileAsync(string, CancellationToken)
InMemoryHttpCacheStore.csLoads cache entries from a JSON file and replaces current in-memory entries.
net10.0
public ValueTask LoadFromFileAsync(string filePath, CancellationToken cancellationToken = default)net11.0
public ValueTask LoadFromFileAsync(string filePath, CancellationToken cancellationToken = default)Parameters
filePathstring- The path of the file to read.
cancellationTokenCancellationToken- The cancellation token.
Returns
PruneObsoleteEntriesAsync overloads
PruneObsoleteEntriesAsync(DateTimeOffset, CancellationToken)
InMemoryHttpCacheStore.csRemoves expired entries that cannot be reused when stale.
public ValueTask PruneObsoleteEntriesAsync(DateTimeOffset now, CancellationToken cancellationToken = default)Parameters
nowDateTimeOffset- The current time used to evaluate expiration.
cancellationTokenCancellationToken- The cancellation token.
Returns
PruneObsoleteEntriesAsync(CancellationToken)
InMemoryHttpCacheStore.csRemoves expired entries that cannot be reused when stale.
public ValueTask PruneObsoleteEntriesAsync(CancellationToken cancellationToken = default)RemoveEntriesAsync(string, CancellationToken)
InMemoryHttpCacheStore.csRemoves all entries associated with a primary cache key.
public ValueTask RemoveEntriesAsync(string primaryKey, CancellationToken cancellationToken)Parameters
primaryKeystring- The primary cache key.
cancellationTokenCancellationToken- The cancellation token.
Returns
SaveToFileAsync(string, CancellationToken)
InMemoryHttpCacheStore.csSaves all in-memory cache entries to a JSON file.
net10.0
public ValueTask SaveToFileAsync(string filePath, CancellationToken cancellationToken = default)net11.0
public ValueTask SaveToFileAsync(string filePath, CancellationToken cancellationToken = default)Parameters
filePathstring- The path of the file to write.
cancellationTokenCancellationToken- The cancellation token.
Returns
SetEntryAsync(string, HttpCachePersistenceEntry, CancellationToken)
InMemoryHttpCacheStore.csAdds or replaces a cache entry for a primary key.
public ValueTask SetEntryAsync(string primaryKey, HttpCachePersistenceEntry entry, CancellationToken cancellationToken)Parameters
primaryKeystring- The primary cache key.
entryHttpCachePersistenceEntry- The entry to store.
cancellationTokenCancellationToken- The cancellation token.