Open sandboxFocus

Class CachingServiceExtensions

Extension methods for the ICachingService interface, providing methods for cache invalidation, dependency management, and cache refresh operations.

Inheritance
CachingServiceExtensions
Namespace: Metalama.Patterns.Caching
Assembly: Metalama.Patterns.Caching.dll
Syntax
public static class CachingServiceExtensions
Remarks

This class provides the primary API for imperative cache operations at run time, including:

Methods

Name Description
AddDependencies(ICachingService, IEnumerable<ICacheDependency>)

Adds multiple ICacheDependency instances to the current caching context.

AddDependencies(ICachingService, IEnumerable<string>)

Adds multiple string dependencies to the current caching context.

AddDependency(ICachingService, ICacheDependency)

Adds an ICacheDependency to the current caching context, so that the cached item will be invalidated when this dependency is invalidated.

AddDependency(ICachingService, string)

Adds a string dependency to the current caching context, so that the cached item will be invalidated when this dependency is invalidated.

AddObjectDependency(ICachingService, object)

Adds an object dependency to the current caching context. The cache key is generated from the object using the same mechanism as with method parameters (using the CacheKeyAttribute aspect or formatters).

Invalidate(ICachingService, ICacheDependency)

Invalidates a cache dependency given as an ICacheDependency, i.e. removes all cache items that are dependent on this dependency.

Invalidate(ICachingService, IReadOnlyCollection<string>)

Invalidates a set of cache dependencies given as string, i.e. removes all cache items that are dependent on these dependency keys.

Invalidate(ICachingService, MethodInfo, object?, params object?[])

Removes a method call result from the cache giving the MethodInfo representing the method, the instance and the arguments of the method call.

Invalidate(ICachingService, string)

Invalidates a cache dependency given as string, i.e. removes all cache items that are dependent on this dependency key.

Invalidate(ICachingService, string, params string[])
InvalidateAsync(ICachingService, ICacheDependency, CancellationToken)

Asynchronously invalidates a cache dependency given as an ICacheDependency, i.e. removes all cache items that are dependent on this dependency.

InvalidateAsync(ICachingService, IReadOnlyCollection<string>, CancellationToken)

Asynchronously invalidates a cache dependency given as string, i.e. removes all cache items that are dependent on this dependency key.

InvalidateAsync(ICachingService, MethodInfo, object?, object?[], CancellationToken)

Asynchronously removes a method call result from the cache giving the MethodInfo representing the method, the instance and the arguments of the method call.

InvalidateAsync(ICachingService, string, params string[])
InvalidateAsync(ICachingService, string, CancellationToken)

Asynchronously invalidates a cache dependency given as string, i.e. removes all cache items that are dependent on this dependency key.

InvalidateAsync<TReturn>(ICachingService, Func<TReturn>, CancellationToken)

Asynchronously removes a method call result from the cache giving the delegate of the method. This overload is for methods with 0 parameter.

InvalidateAsync<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TReturn>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, CancellationToken)

Asynchronously removes a method call result from the cache giving the delegate of the method. This overload is for methods with 9 parameters.

InvalidateAsync<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10, TReturn>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10, CancellationToken)

Asynchronously removes a method call result from the cache giving the delegate of the method. This overload is for methods with 10 parameters.

InvalidateAsync<TReturn, TParam1>(ICachingService, Func<TParam1, TReturn>, TParam1, CancellationToken)

Asynchronously removes a method call result from the cache giving the delegate of the method. This overload is for methods with 1 parameter.

InvalidateAsync<TReturn, TParam1, TParam2>(ICachingService, Func<TParam1, TParam2, TReturn>, TParam1, TParam2, CancellationToken)

Asynchronously removes a method call result from the cache giving the delegate of the method. This overload is for methods with 2 parameters.

InvalidateAsync<TReturn, TParam1, TParam2, TParam3>(ICachingService, Func<TParam1, TParam2, TParam3, TReturn>, TParam1, TParam2, TParam3, CancellationToken)

Asynchronously removes a method call result from the cache giving the delegate of the method. This overload is for methods with 3 parameters.

InvalidateAsync<TReturn, TParam1, TParam2, TParam3, TParam4>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TReturn>, TParam1, TParam2, TParam3, TParam4, CancellationToken)

Asynchronously removes a method call result from the cache giving the delegate of the method. This overload is for methods with 4 parameters.

InvalidateAsync<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TReturn>, TParam1, TParam2, TParam3, TParam4, TParam5, CancellationToken)

Asynchronously removes a method call result from the cache giving the delegate of the method. This overload is for methods with 5 parameters.

InvalidateAsync<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TReturn>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, CancellationToken)

Asynchronously removes a method call result from the cache giving the delegate of the method. This overload is for methods with 6 parameters.

InvalidateAsync<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TReturn>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, CancellationToken)

Asynchronously removes a method call result from the cache giving the delegate of the method. This overload is for methods with 7 parameters.

InvalidateAsync<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TReturn>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, CancellationToken)

Asynchronously removes a method call result from the cache giving the delegate of the method. This overload is for methods with 8 parameters.

InvalidateObject(ICachingService, object)

Invalidates a cache dependency given an object, i.e. removes all cached items that are dependent on that object. The cache key is generated from the object using the same mechanism as with parameters, i.e. using IFormattable<T>, Formatter<T>, ToString() or ISpanFormattable.

InvalidateObjectAsync(ICachingService, object, CancellationToken)

Asynchronously invalidates a cache dependency given an object, i.e. removes all cached items that are dependent on that object. The cache key is generated from the object using the same mechanism as with parameters, i.e. using IFormattable<T>, Formatter<T>, ToString() or ISpanFormattable.

Invalidate<TReturn>(ICachingService, Func<TReturn>)

Removes a method call result from the cache giving the delegate of the method. This overload is for methods with 0 parameter.

Invalidate<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TReturn>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9)

Removes a method call result from the cache giving the delegate of the method. This overload is for methods with 9 parameters.

Invalidate<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10, TReturn>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10)

Removes a method call result from the cache giving the delegate of the method. This overload is for methods with 10 parameters.

Invalidate<TReturn, TParam1>(ICachingService, Func<TParam1, TReturn>, TParam1)

Removes a method call result from the cache giving the delegate of the method. This overload is for methods with 1 parameter.

Invalidate<TReturn, TParam1, TParam2>(ICachingService, Func<TParam1, TParam2, TReturn>, TParam1, TParam2)

Removes a method call result from the cache giving the delegate of the method. This overload is for methods with 2 parameters.

Invalidate<TReturn, TParam1, TParam2, TParam3>(ICachingService, Func<TParam1, TParam2, TParam3, TReturn>, TParam1, TParam2, TParam3)

Removes a method call result from the cache giving the delegate of the method. This overload is for methods with 3 parameters.

Invalidate<TReturn, TParam1, TParam2, TParam3, TParam4>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TReturn>, TParam1, TParam2, TParam3, TParam4)

Removes a method call result from the cache giving the delegate of the method. This overload is for methods with 4 parameters.

Invalidate<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TReturn>, TParam1, TParam2, TParam3, TParam4, TParam5)

Removes a method call result from the cache giving the delegate of the method. This overload is for methods with 5 parameters.

Invalidate<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TReturn>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6)

Removes a method call result from the cache giving the delegate of the method. This overload is for methods with 6 parameters.

Invalidate<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TReturn>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7)

Removes a method call result from the cache giving the delegate of the method. This overload is for methods with 7 parameters.

Invalidate<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TReturn>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8)

Removes a method call result from the cache giving the delegate of the method. This overload is for methods with 8 parameters.

RefreshAsync<TReturn>(ICachingService, Func<Task<TReturn>>, CancellationToken)

Asynchronously evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 0 parameter.

RefreshAsync<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, Task<TReturn>>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, CancellationToken)

Asynchronously evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 9 parameters.

RefreshAsync<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10, Task<TReturn>>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10, CancellationToken)

Asynchronously evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 10 parameters.

RefreshAsync<TReturn, TParam1>(ICachingService, Func<TParam1, Task<TReturn>>, TParam1, CancellationToken)

Asynchronously evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 1 parameter.

RefreshAsync<TReturn, TParam1, TParam2>(ICachingService, Func<TParam1, TParam2, Task<TReturn>>, TParam1, TParam2, CancellationToken)

Asynchronously evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 2 parameters.

RefreshAsync<TReturn, TParam1, TParam2, TParam3>(ICachingService, Func<TParam1, TParam2, TParam3, Task<TReturn>>, TParam1, TParam2, TParam3, CancellationToken)

Asynchronously evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 3 parameters.

RefreshAsync<TReturn, TParam1, TParam2, TParam3, TParam4>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, Task<TReturn>>, TParam1, TParam2, TParam3, TParam4, CancellationToken)

Asynchronously evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 4 parameters.

RefreshAsync<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, Task<TReturn>>, TParam1, TParam2, TParam3, TParam4, TParam5, CancellationToken)

Asynchronously evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 5 parameters.

RefreshAsync<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, Task<TReturn>>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, CancellationToken)

Asynchronously evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 6 parameters.

RefreshAsync<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, Task<TReturn>>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, CancellationToken)

Asynchronously evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 7 parameters.

RefreshAsync<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, Task<TReturn>>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, CancellationToken)

Asynchronously evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 8 parameters.

Refresh<TReturn>(ICachingService, Func<TReturn>)

Evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 0 parameter.

Refresh<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TReturn>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9)

Evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 9 parameters.

Refresh<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10, TReturn>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10)

Evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 10 parameters.

Refresh<TReturn, TParam1>(ICachingService, Func<TParam1, TReturn>, TParam1)

Evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 1 parameter.

Refresh<TReturn, TParam1, TParam2>(ICachingService, Func<TParam1, TParam2, TReturn>, TParam1, TParam2)

Evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 2 parameters.

Refresh<TReturn, TParam1, TParam2, TParam3>(ICachingService, Func<TParam1, TParam2, TParam3, TReturn>, TParam1, TParam2, TParam3)

Evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 3 parameters.

Refresh<TReturn, TParam1, TParam2, TParam3, TParam4>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TReturn>, TParam1, TParam2, TParam3, TParam4)

Evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 4 parameters.

Refresh<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TReturn>, TParam1, TParam2, TParam3, TParam4, TParam5)

Evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 5 parameters.

Refresh<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TReturn>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6)

Evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 6 parameters.

Refresh<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TReturn>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7)

Evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 7 parameters.

Refresh<TReturn, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8>(ICachingService, Func<TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TReturn>, TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8)

Evaluates a method, ignoring the currently cached value, and replaces the corresponding cache item with the new return value of the method. This overload is for methods with 8 parameters.

SuspendDependencyPropagation(ICachingService)

Temporarily suspends propagation of dependencies from subsequently called methods to the caller method.

See Also