Developer forum

Forum » Dynamicweb 10 » Custom services caches not shown

Custom services caches not shown

Anders Ebdrup
Reply

Hi DW,

 

We experience at least on this version: 10.17.8, that our custom services are not shown in the list below, but they are shown in our local development environments. Our tricks to make them work in the cloud environment as well?

Best regards, Anders


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Can you show us your service code?

 
Anders Ebdrup
Reply

Yes, of course. This is the code that is working local, but not in the cloud:

 

 public class CustomFacetCacheService : ICacheStorage<string, object>
 {
     private static readonly Lazy<CustomFacetCacheService> _instance = new(() => new CustomFacetCacheService());
     public static CustomFacetCacheService Instance => _instance.Value;

     private static ServiceCache<string, object> ServiceCacheStorage { get; set; }
     CacheInformation ICacheStorage.Info => ServiceCacheStorage.Info;

     static CustomFacetCacheService()
     {
         ServiceCacheStorage = new DictionaryCache<string, object>(typeof(CustomFacetCacheService))
         {
             InitializeCache = InitializeCache,
             FetchOnNotFound = UpdateCache,
             RefreshOnClear = UpdateCache
         };
     }

     private static Dictionary<string, object> InitializeCache()
     {
         return [];
     }

     private static Dictionary<string, object> UpdateCache(IEnumerable<string>? ids)
     {
         ids = ids?.Where(key => key is not null).Distinct(StringComparer.OrdinalIgnoreCase);
         if ((ids?.Any()) != true == true)
         {
             return [];
         }

         return [];
     }

     public object? Get(string key)
     {
         var value = ServiceCacheStorage.GetCache(key);
         return ServiceCacheStorage.GetCache(key);
     }

     public void SetCache(string key, object value)
     {
         ServiceCacheStorage.SetCache(key, value);
     }

     public void ClearCache()
     {
         ServiceCacheStorage.ClearCache();
     }

     public void SetCacheType<TObjectCache>() where TObjectCache : ServiceCache<string, object>
     {
     }

     public void ClearCache(IEnumerable<string> keys)
     {
         ServiceCacheStorage.ClearCache(keys);
     }

     public void ClearCache(string key)
     {
         ServiceCacheStorage.ClearCache(key);
     }
 }

 
Kristian Elmholt Kjær Dynamicweb Employee
Kristian Elmholt Kjær
Reply

Hi Anders,

 

How do you install the assembly with this new "CustomFacetCacheService"? Via nuget?

 

And if so, have you tried recycling the site to see if this makes it show up?

 

/Kristian

 
Anders Ebdrup
Reply

Hi Kristian,

 

Thanks for looking into it.

We install the assemblies through the CLI, and we have tried to recycle the application afterwards.

The CLI command is: dw install "$nupkg" --host ${{ parameters.hostUrl }} --apiKey ${{ parameters.apiKey }}

 

Best regards, Anders

 

You must be logged in to post in the forum