Cache Dependency means that an item can be removed from the cache when a dependent entity gets changed.
There are 2 types of cache dependencyies.
1)File dependency
2)Key dependency
File dependency
This provides an option to remove an item automatically from the cache whenever a disk file changes.
Syntax:
object Data;
//Load Data from errorList.xml
CacheDependency fileDependency = new CacheDependency(Server.MapPath("errorList.xml"));
Cache.Insert("ERROR_LIST", Data, fileDependency);
when ever the errorList.xml has changed,EROR_LIST item will be removed from cache automatically.
Key dependency
Key dependency is similar to file dependency and it dependent on another item in the cache and gets invalidated when the dependent item gets changed or removed.
No comments:
Post a Comment