Does anyone know if anything has changed recently with the dictionary cache logic?
We upgraded a few websites to the latest v13.10.1 and since deployment noticed a lot of database hits, after looking into it, appears to be the dictionary queries.
My understanding was, if a dictionary item key was not in the cache it would query the db and then store that response in a cache is this not the case? As we certainly was not seeing this level of reads previously but it’s proving hard to debug at the moment so thought I’d ask here as well.
I used a bit of AI to research what could have changed and this is what it came up with, sounds plausible:
What the code did before
CultureDictionaryFactory would look up dictionary values and cache both hits and misses.
That means:
If a key existed, its value was cached in-memory.
If a key didn’t exist, a “negative cache” entry (e.g. null/empty) was stored so repeated lookups wouldn’t hit the database again.
What changed (the regression)
In 13.10, Umbraco switched its internal caching to use HybridCache (wrapping MemoryCache).
During this refactor:
The “negative caching” logic for missing keys was dropped.
The GetDictionaryValueOrDefault method now only caches found values.
When you call it with a missing or newly-created key, the lookup always hits the database (and may not refresh correctly until the cache is explicitly invalidated).