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.
CacheManager
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.
SystemManager.GetCacheManager
CacheManagerInstance
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:
Add
CacheItemPriority
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.
GetData
To remove an item from application cache you must use the Remove method of the cache manager instance and pass the cache item key.
Remove
The following sample demonstrates working with application cache:
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important