Open sandboxFocus

Interface IValueAdapter

Wraps uncacheable classes or interfaces into cacheable objects, for instance an IEnumerable may be wrapped into an array.

Namespace: Metalama.Patterns.Caching.ValueAdapters
Assembly: Metalama.Patterns.Caching.dll
Syntax
public interface IValueAdapter
Remarks

Value adapters are used when a cached method returns a type that cannot be directly cached, such as IEnumerable<T>, Stream, or IEnumerator<T>. The adapter converts the value to a cacheable form before storing and converts it back when retrieving.

To register a custom value adapter, use the ICachingServiceBuilder.AddValueAdapter method.

Properties

Name Description
IsAsyncSupported

Gets a value indicating whether the GetStoredValueAsync(object?, CancellationToken) method is supported.

Methods

Name Description
GetExposedValue(object?)

Gets the value that should be exposed to the consuming application, i.e. typically the return value of the cached method.

GetStoredValue(object?)

Gets the value that should be stored in the cache.

GetStoredValueAsync(object?, CancellationToken)

Asynchronously gets the value that should be stored in the cache.

Extension Methods

See Also