The Problem
If you are involved in an upgrade project where you were still on an older version of Sitecore like 8.2 and have a personalized cache implementation relying on Sitecore CustomCache, it is possible that you are utilizing the Sitecore.Caching.CacheManager.FindCacheByName(string name) method. This particular method assists in retrieving a cache object based on the cache name (key). You may encounter issues with the FindCacheByName(string name) method no longer functioning, which is a result of the modifications Sitecore has made in implementing cache logics.
The Analysis
Sitecore has implemented generics within its site caching framework. Further details can be found at the following link:
https://doc.sitecore.com/xp/en/developers/82/sitecore-experience-platform/cache-api-changes.html#changes-in-the-cachemanager-class.
As a result of this update, when utilizing the FindCacheByName() method, it is necessary to indicate the type of key, as demonstrated in the example below.
Sitecore.Caching.CacheManager.FindCacheByName<string>("cache name")
If not, your code will error out.
Sitecore.Caching.Generics
Sitecore.Caching.Generics allows developers to use object types as keys. Objects as keys allows for greater flexibility in how data is cached, but using objects as cache keys introduces some potential issues (for example, cache misses due to incorrect object equality comparisons).
Hope this helps you!!
Comments
Post a Comment