I am struggling to figure out what the Sitecore.Caching.CachePriority enum type is used for.

The type looks somewhat similar to .NET's System.Web.Caching.CacheItemPriority type, however, the values are slightly different and the Sitecore type does not appear to map to the native type anywhere. If I assume that the two are meant to function similarly, this would imply that the Sitecore.Caching.CachePriority enum type is meant to control the priority in which Sitecore caches and/or their entries would be evicted (lower priorities being evicted before higher priorities), in the case of high memory usage. However, when looking at the decompiled Sitecore.Caching.Cache<T> and the nested Sitecore.Caching.Cache<T>.CacheEntry classes, each has a property holding the CachePriority for each but that property does not appear to be used anywhere.

Can anyone help to clarify the purpose of the Sitecore.Caching.CachePriority type, including where it is used and what for?

  • I'm pretty sure you are correct. It isn't currently used. I think it has been in the API for a long time, but I'm not sure if it was ever used.
    – Ben Golden
    Commented Jul 7, 2017 at 4:17
  • 1
    That's upsetting. I'll file a Sitecore Support ticket to get an official answer on this one then. I'll update this post once I receive word back from Sitecore. Commented Jul 7, 2017 at 13:54

2 Answers 2


You are 100% correct - Sitecore.Caching.Generics.Cache<T>.CacheEntry is not used out of the box to prioritize cache entries in any way. My guess is that CachePriority property is meant to be used by custom ICache<T> implementations.

Furthermore, each item added to the cache gets a default priority which is Sitecore.Caching.CachePriority.Normal. It can be overridden in configuration file by specifying value for "Caching.Priority" setting.

Disassembled code for Sitecore.Configuration.Settings.Caching.DefaultPriority:

        string setting = Settings.GetSetting("Caching.Priority");
        if (setting.Length > 0)
            Enum.Parse(typeof(CacheItemPriority), setting, true);
        return CachePriority.Normal;
  • Actually, I'm fairly certain that the default priority is Sitecore.Caching.CachePriority.Lowest, given that CachePriority.Normal is not manually assigned anywhere and the default value of the enum is CachePriority.Lowest. Commented Jul 10, 2017 at 13:02
  • @Zachary Kniebel please have a look at the edited answer.
    – grg
    Commented Jul 10, 2017 at 13:12
  • You are correct about the default priority! Thanks - not sure why that didn't come up when looking for usages. I'm going to hold out for an official answer from Sitecore Support regarding the intended use of the CachePriority as well, but +1 for the answer and default priority Commented Jul 10, 2017 at 13:23

After conferring with Sitecore Support, it was their determination as well that the Sitecore.Caching.CachePriority enum type has not been used since Sitecore 5.1.

Additionally, note that the related Caching.Priority config setting is not even taken into account, and the CachePriority.Normal is always returned (see @grg's answer or the decompiled source of the Sitecore.Configuration.Settings.Caching.DefaultPriority propert).

From Sitecore Support in regards to the eviction flow:

In the current caching implementation, the eviction happens when a new key should be added, but there is not enough space left to add it. When a new entry is added to the cache, the CheckSize method checks if there is enough space. If not, cache entries should be evicted or the whole cache should be cleared.

The Scavenge method performs eviction (or cleanup, if necessary). Note: as a result, the scavenge is not performed in case the cache size limits are disabled.

By default, the DefaultScavengeStrategy is used. This strategy does not take the priority of the cache or cache entries into the account. There are no other strategies available by default. Therefore, it looks like the CachePriority is obsolete as well as the related properties.

We have registered a bug related to the unused CachePriority enum and the related Caching.Priority configuration setting (reference number 93317).

Sitecore Support later clarified the nature of the bug:

The bug is related to the fact that there are unused configuration settings, enums and properties.

It is not specified if this functionality should be deleted or included in the eviction logic. Therefore, hat's up to developers to review it and decide if the cache priority can be used to improve the eviction functionality (for example, by adding a new scavenge strategy) or there are some potential drawbacks and this functionality should be deprecated.

Hopefully, the developers at Sitecore will see this post and realize that there is value in either adding in the missing cache priority logic and/or making it possible to write custom scavenge strategies.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.