Class FileContentCache
- Namespace
- Homa.Sdk.Foundation
- Assembly
- Homa.Sdk.Foundation.dll
Stores content as files, according to the given FileRetentionPolicy.
public class FileContentCache : IContentCache
- Inheritance
-
FileContentCache
- Implements
- Inherited Members
Constructors
FileContentCache(IFileSystem, ILogger, ITime, IMetricRecorderFactory, string, FileContentCacheOptions)
Creates an instance of FileContentCache.
public FileContentCache(IFileSystem fileSystem, ILogger logger, ITime time, IMetricRecorderFactory metricRecorderFactory, string directory, FileContentCacheOptions options)
Parameters
fileSystemIFileSystemThe file system the content will be written on.
loggerILoggerThe logger to use.
timeITimeThe time to use to see if content is outdated and should be pruned.
metricRecorderFactoryIMetricRecorderFactoryThe metric recorder factory to use for recording metrics.
directorystringThe directory the content should be stored in.
optionsFileContentCacheOptionsOptions used to configure the content cache.
Methods
Clear()
Removes all cached content from the cache.
public Task Clear()
Returns
Initialize()
Initializes the content cache.
public Task Initialize()
Returns
Remarks
Calling this method will increase the session number.
Prune(CancellationToken)
Removes outdated files from disk, according to the given FileRetentionPolicy.
public Task Prune(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
RemoveContent(string)
Removes the content associated to the given ID in the cache.
public Task<bool> RemoveContent(string id)
Parameters
idstringThe ID of the content to remove.
Returns
RetrieveContent(string, CancellationToken)
Gets content associated to the given ID from the cache.
public Task<string> RetrieveContent(string id, CancellationToken cancellationToken = default)
Parameters
idstringThe ID of the content to fetch.
cancellationTokenCancellationTokenThe cancellation token to use for that task.
Returns
StoreContent(string, string, CancellationToken)
Sets the content associated to the given ID in the cache.
public Task StoreContent(string id, string content, CancellationToken cancellationToken = default)
Parameters
idstringThe ID of the content to store.
contentstringThe content to store in the cache.
cancellationTokenCancellationTokenThe cancellation token to use for that task.