AI OnAI Off
Hi Andreas
I wrote this a little while back about cache keys and master keys: https://stefanolsen.com/posts/caching-custom-data-that-depends-on-episerver-content/
Generally, individual cache keys are good if you want to depend on a specific piece of content. Master keys are good if you want to depend on any or all instances of a kind. That is for CMS.
When caching data based on a commerce entry, I would typically depend on master keys. Unless I find that I can depend on a more specific cache key.
I'm in the process of caching some commerce content with dependencies, and I'm not sure if I should use MasterCacheKeys or IContentCacheKeyCreator to create cache dependencies. Looking at the source codes, it appears that the generated strings are completely different, so I guess they fulfill different purposes.
What's the difference between them and when should each be used?
For simplicity, I'm using CatalogContentLoader.GetCacheMasterKeys() to create cache keys, which in turn makes use of MasterCacheKeys.