You can benefit from the Sitefinity CMS application cache in your custom implementation to store items that are either expensive to process. This way you increase your application performance. Items are stored in application cache via the respective cache managers. You can store, retrieve and remove items from application cache.
To work with application cache must first get an instance of the CacheManager you want to work with. Different cache managers define different sections of the application cache and have their own polling and scavenging behavior. For more information see Administration: Configure Application cache.
To get an instance of a cache manager you must use the SystemManager.GetCacheManager method. When working with SystemManager.GetCacheManager method you can instantiate one of the default cache managers by using the CacheManagerInstance enum or get an instance of a custom cache manager by passing its Name as a string.
You add items in cache via using the to use the Add method of the CacheManager. When adding items to application cache you must to specify the following additional parameters:
NOTE: If you do not explicitly set the expiration period and the priority properties, they are set to the default settings. The respective default settings are NeverExpired and Normal.
You get items from application cache by calling the GetData method of the cache manager instance and passing the cache item key. GetData returns the items as generic objects so you need to cast them to their proper type.
To remove an item from application cache you must use the Remove method of the cache manager instance and pass the cache item key.
The following sample demonstrates working with application cache:
Sign up for our free beginner training. Boost your credentials through advanced courses and certification. Register for Sitefinity training and certification.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important