user5002462
user5002462

Reputation:

How Umbraco GetDictionaryItem works

I am using Visual Studio 2015 in debug mode, and running Diagnostic tool. The Umbraco version is 7.5.3

My question is:

Do umbraco always travel back to database everytime it use GetDictionaryItem?

As you can see in my screenshot, everytime I debug, an event was showing it was querying at database, please somebody enlighten me. Thanks

enter image description here

Upvotes: 0

Views: 1698

Answers (1)

Marcin Zajkowski
Marcin Zajkowski

Reputation: 1728

umbraco.library is getting obsolete - don't use it.

To get dictionary value, just use Umbraco.Field("#aliasOfField"). You can test it using graphic UI in templates section. Second icon from left side is the one responsible for dictionary items. It's retrieved from XML cache, so there is no need to ping database for getting any value to present on the site.

enter image description here

Database Caching

Umbraco.Field() uses the Published Content xml cache loaded into memory (from ~/App_Data/Umbraco.config), but Umbraco.GetDictionaryValue() will hit the database if the key doesn't exist in the in-memory cache already. Once it's retrieved the value the first time around though, it should use the cache for subsequent calls as long as the app isn't restarted.

Upvotes: 2

Related Questions