Posted on 15/11/2018 15:13:55
We have looked into this - and this is what our developer found - basically it only caches for 5 minutes.
Namespace Content.Items.Metadata
Public Class FieldOptionMetadataSqlSource
...
Public Overrides Property Values As FieldOptionMetadataCollection
Get
If IsNothing(Cache.Current.Item(CacheKey)) Then
Cache.Current.AddOrUpdate(CacheKey, GetData(), New CacheItemPolicy() With {.AbsoluteExpiration = Date.Now.AddMinutes(5)})
End If
Return Cache.Current.Get(Of FieldOptionMetadataCollection)(CacheKey)
End Get
Set(value As FieldOptionMetadataCollection)
Cache.Current.AddOrUpdate(CacheKey, GetData(), New CacheItemPolicy() With {.AbsoluteExpiration = Date.Now.AddMinutes(5)})
End Set
End Property
By the way It have clear cache api, but it is not so simple to call it
Dynamicweb.Content.Items.Metadata.ItemType itemTypeWithSqlSource = Dynamicweb.Content.Items.ItemManager.Metadata.GetItemType("SQLSource");
Dynamicweb.Content.Items.Metadata.ItemField fieldWithSqlSource = itemTypeWithSqlSource.Fields.FirstOrDefault(field => field.SystemName.Equals("Sqlsourced", StringComparison.OrdinalIgnoreCase));
Dynamicweb.Content.Items.Metadata.FieldOptionMetadataSource sqlOptionSource = fieldWithSqlSource.Options.Source;
sqlOptionSource.Update(); //this clears the cache of specific field source
Also I've tried to check frontend for that issue using Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> template
and there is no such problem - every time page is loaded options fetched from sql due cache key compose implementation.