none
Migrate from Managed Cache Service to Azure Cache for Redis RRS feed

  • Question

  • Here is my existing application used "Microsoft.ApplicationServer.Caching". Now latest Azure

    Virtual Machine or App service won't support.

    ErrorCode<ERRCA0017>:SubStatus<ES0006>:

    There is a temp failure. (One or More specified cache servers

    are unavailable.

    Hence planed to migrate to Azure Redis cache. May i get some idea or suggestion for the

    below methods Azure redis cache system from Azure Managed cache.

    using Core.Common.Extensions; namespace Core.Common.Caching { using System.Collections.Specialized; using Microsoft.ApplicationServer.Caching; public class AzureCacheProvider : ICacheProvider { private readonly NameValueCollection appSettings; public AzureCacheProvider(NameValueCollection appSettings) { this.appSettings = appSettings; } #region Public Methods and Operators public T GetCacheItem<T>(string cacheKey, string configKey) { return this.GetCacheItem<T>(cacheKey, configKey, "default"); } public T GetCacheItem<T>(string cacheKey, string configKey, bool isSerialized) { throw new System.NotImplementedException(); } public T GetCacheItem<T>(string cacheKey, string configKey, string logicalCacheName) { var obj = default(T); if (this.appSettings[configKey].ToBool()) { using (var cacheFactory = new DataCacheFactory(new DataCacheFactoryConfiguration(logicalCacheName))) { var defaultCache = cacheFactory.GetDefaultCache(); return (T)defaultCache.Get(cacheKey); } } return obj; } public void SetCacheItem<T>(string cacheKey, string configKey, T item) { this.SetCacheItem(cacheKey, configKey, item, "default"); } public void SetCacheItem<T>(string cacheKey, string configKey, T item, string logicalCacheName) { if (this.appSettings[configKey].ToBool()) { using (var cacheFactory = new DataCacheFactory(new DataCacheFactoryConfiguration(logicalCacheName))) { var defaultCache = cacheFactory.GetDefaultCache(); defaultCache.Put(cacheKey, item); } } } public void RemoveCacheItem(string cacheKey, string configKey) { this.RemoveCacheItem(cacheKey, configKey, "default"); } public void RemoveCacheItem(string cacheKey, string configKey, string logicalCacheName) { if (!this.appSettings[configKey].ToBool()) { return; } using (var cacheFactory = new DataCacheFactory(new DataCacheFactoryConfiguration(logicalCacheName))) { var defaultCache = cacheFactory.GetDefaultCache(); defaultCache.Remove(cacheKey); } } #endregion } }





    Wednesday, March 6, 2019 12:54 PM

All replies

  • Hello AAzath

    Please check this article for guidance on migrating managed cache service to Azure Cache for Redis.

    What is you cache size?

    If the size is considerably small and your app can build the cache on start up, you can consider using InMemory Caching in .Net Core as well. 

    • Proposed as answer by angoyal-msft Thursday, March 7, 2019 5:43 AM
    Thursday, March 7, 2019 4:17 AM
    Moderator
  • Just checking in to see if the above answer helped.

    If this answers your query, do click “Mark as Answer” and Up-Vote for the same which might be beneficial to other community members reading this thread. 


    Thursday, March 7, 2019 4:52 PM
    Moderator