Custom Cache Dependencies
Note
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 Extensibility provides an alternative EvaluateBulk method that evaluates multiple items at a time.
And the third dependency class provided by NCache is NotifyExtensibleDependency where the client is responsible for providing the dependency logic as well as a delegate to invoke that logic in order to remove data from the cache.
Like expiration, cache clean up thread periodically calls the HasChanged()
and EvaluateBulk()
properties and on being True, the items are removed from the cache. NotifyExtensibleDependency
however, doesn't call the clean up thread for removing items from the cache. It deploys its own handler on the cache that is responsible for removing items from the cache.
See Also
Sync Cache using Extensible Dependency
Sync Cache using Bulk Extensible Dependency
Sync Cache using Notify Extensible Dependency
Configure Custom Dependencies