Custom Cache Dependencies
This feature is only available in NCache Enterprise Edition.
NCache provides flexible ways to determine data invalidation using various dependencies. However, you can implement your custom logic for dependency if none of the built-in invalidation strategies fulfill your requirements.
In custom dependency, you can implement your custom logic which defines when certain data becomes invalid. Here, the concept of multithreading has been incorporated, meaning that instead of executing each item sequentially, multiple threads are introduced to perform expiration simultaneously. For example, you can implement a custom dependency which makes a call to a web service for the validation of data depending upon your application's functionality.
There are three distinct custom dependency classes provided to you by NCache. The first one is known as ExtensibleDependency class that allows you to implement your custom expiry logic against which data is expired one item at a time. All you need to do is inherit your dependency class from
ExtensibleDependency and override its HasChanged property.
The second class is BulkExtensibleDependency which allows multiple expirations against one call. Instead of the
HasChanged property, Bulk Extensible Dependency provides an alternate EvaluateBulk method that evaluates multiple items at a time.
The third dependency class provided by NCache is NotifyExtensibleDependency where the user is responsible for providing the dependency logic that calls a delegate provided by NCache to invoke that logic in order to remove data from the cache.
Like expiration, cache clean up thread periodically calls the
HasChanged property and
EvaluateBulk() method and on returning true, the items are removed from the cache.
NotifyExtensibleDependency however, doesn’t depend on the clean up thread for removing items from cache. It deploys its own handler on the cache that is responsible for removing items from the cache.