Open sandboxFocus

Interface IValueAdapter

Wraps uncacheable classes or interfaces into cacheable objects. For example, an IEnumerable can be wrapped into an array.

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

The value returned by the cached method is called the exposed value. The value that is stored in the cache is called the stored value. The adapter is selected by the return type of the cached method (for an async method, the result type of the task). Adapters for Stream, IEnumerable<T> and IEnumerator<T> are registered by default. A null return value is stored without calling the adapter.

To add an adapter, implement IValueAdapter<T>, typically by deriving from ValueAdapter<T>, and register it with the ValueAdapterFactory of the backend, available from the ValueAdapters property.

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, which is 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.

See Also