Dependencies in cache: -
When you add an item to the cache, you can define dependency relationships that can force that item to be removed from the cache under specific activities of dependencies.Example if the cache object is dependent on file and when the file data changes you want the cache object to be update.
Types of dependencies: -
Following are the supported dependency:-
- File dependency: - Allows you to invalidate a specific cache item when a disk based file or files change.
- Time-based expiration: - Allows you to invalidate a specific cache item depending on predefined time.
- Key dependency:- Allows you to invalidate a specific cache item depending when another cached item changes.
Cache Callback in Cache: -
Cache object is dependent on its dependencies example file based, time based etc…Cache items remove the object when cache dependencies change.ASP.NET provides capability to execute a callback method when that item is removed from cache
Also see following ASP.NET caching interview questions video on difference between Session VS Viewstate: -