RtMemoryCache accepts invalid priorities

Description

RtMemoryCache accepts the same priority ranges than SysCache, but in fact the underlying cache only handle a normal priority and a "never remove" priority, which usage is advised against.
Remove priority handling from RtMemoryCache.

Environment

None

Activity

Show:

Frédéric Delaporte October 24, 2017 at 9:40 AM
Edited

Priority was accepting values ranging from 1 to 6 (recommended 5 max, 6 matching NotRemovable on SysCache side), with one being the lowest priorty (first to get removed in case of memory stress). But for System.Runtime.Cache the only valid values are 0 (Default) and 1 (NotRemovable). System.Runtime.Cache current code seems to only ever test for NotRemovable, so value 2 to 6 were behaving like Default while 1 was behaving as highest priority: just the other way round than what was intended.

Since the thing was indeed broken, priority is now ignored by RtMemoryCache. Better ignore it than doing the opposite of what it was supposed to do. If having the ability to specify NotRemovable is needed, a new setting should be added, maybe directly named NotRemovable and taking a boolean, since there is not actually any level of priority in System.Runtime.Cache excepted forbidding expiry on memory stress.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created October 23, 2017 at 6:04 PM
Updated October 24, 2017 at 9:42 AM
Resolved October 23, 2017 at 6:49 PM
Who's Looking?