Table of Contents

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

fileSystem IFileSystem

The file system the content will be written on.

logger ILogger

The logger to use.

time ITime

The time to use to see if content is outdated and should be pruned.

metricRecorderFactory IMetricRecorderFactory

The metric recorder factory to use for recording metrics.

directory string

The directory the content should be stored in.

options FileContentCacheOptions

Options used to configure the content cache.

Methods

Clear()

Removes all cached content from the cache.

public Task Clear()

Returns

Task

Initialize()

Initializes the content cache.

public Task Initialize()

Returns

Task

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

cancellationToken CancellationToken

Returns

Task

RemoveContent(string)

Removes the content associated to the given ID in the cache.

public Task<bool> RemoveContent(string id)

Parameters

id string

The ID of the content to remove.

Returns

Task<bool>

True if any content was removed, false otherwise

RetrieveContent(string, CancellationToken)

Gets content associated to the given ID from the cache.

public Task<string> RetrieveContent(string id, CancellationToken cancellationToken = default)

Parameters

id string

The ID of the content to fetch.

cancellationToken CancellationToken

The cancellation token to use for that task.

Returns

Task<string>

The content associated to the ID, or null if it is not in the cache.

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

id string

The ID of the content to store.

content string

The content to store in the cache.

cancellationToken CancellationToken

The cancellation token to use for that task.

Returns

Task