Class CacheDependencyCollector
Collects cache dependencies within a scoped context. Supports nested contexts through the use of the 'using' statement.
public sealed class CacheDependencyCollector
- Inheritance
-
objectCacheDependencyCollector
- Extension Methods
Remarks
This class is designed to be used within a 'using' statement to ensure proper disposal and restoration of the parent context.
The dependencies are automatically collected inside of Kentico.Content.Web.Mvc.ContentRetriever.
Constructors
CacheDependencyCollector()
Initializes a new instance of the CacheDependencyCollector class. Creates a new scope for cache dependency collection.
public CacheDependencyCollector()
Methods
AddCacheDependency(CMSCacheDependency)
Adds a cache dependency to the current collection scope.
public static void AddCacheDependency(CMSCacheDependency dependency)
Parameters
dependency
CMSCacheDependencyThe cache dependency to add.
Remarks
The dependency is added to the parent after the current CacheDependencyCollector is disposed.
Exceptions
- ArgumentNullException
Thrown when dependency is null.
- InvalidOperationException
Thrown when not inside a CacheDependencyCollector scope.
Dispose()
Restores the parent collection scope when this instance is disposed.
public void Dispose()
GetCacheDependency()
Gets a combined cache dependency from all dependencies collected in the current scope.
public CMSCacheDependency GetCacheDependency()
Returns
- CMSCacheDependency
A combined cache dependency.
Exceptions
- ObjectDisposedException
Thrown when the collector has been disposed.