我在我们的Web应用程序中使用Azure托管缓存服务 . 我们将一些对象存储在缓存中以及会话中 . 我们以前没有使用缓存服务来存储会话状态以外的任何内容 . 有一天,我将缓存从基本产品升级到标准产品,并开始缓存一些对象 . 现在我看到有关缓存的这些错误:

ErrorCode:SubStatus:暂时失败 . 请稍后重试

这些错误的堆栈跟踪是

来源:Microsoft.ApplicationServer.Caching.Client StackTrace:在Microsoft.ApplicationServer.Caching.SocketClientProtocol的Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ErrStatus errStatus,Guid trackingId,Exception responseException,Byte [] [] payload,EndpointID destination) Microsoft.ApplicationServer上的Microsoft.ApplicationServer.Caching.SocketClientProtocol.Upsert(VelocityPacketType类型,字符串键,对象值,DataCacheItemVersion oldVersion,TimeSpan超时,DataCacheTag []标记,字符串区域,IMonitoringListener侦听器)中的.ExecuteApi(IVelocityRequestPacket请求,IMonitoringListener侦听器) .Caching.SocketClientProtocol.Put(String key,Object value,DataSpacheItemVersion oldVersion,TimeSpan timeout,DataCacheTag [] tags,String region,IMonitoringListener listener)at Microsoft.ApplicationServer.Caching.DataCache.InternalPut(String key,Object value,DataCacheItemVersion oldVersion, TimeSpan超时,DataCacheTag []标签,字符串区域,IMonitoringLi在Microsoft.ApplicationServer的Microsoft.ApplicationServer.Caching.MonitoringListenerFactory.EmptyListener.Microsoft.ApplicationServer.Caching.IMonitoringListener.Listen [TResult](Func1 innerDelegate)上的Microsoft.ApplicationServer.Caching.DataCache . <> c__DisplayClass2f.b__2e()处获得stener listener) Microsoft.Web.DistributedCache.DataCacheForwarderBase的Microsoft.Web.DistributedCache.DataCacheWrapper.Put(String key,Object value,TimeSpan timeout)中的.Caching.DataCache.Put(String key,Object value,TimeSpan timeout) . <> c__DisplayClass13 . <将> b__12()放在Microsoft.Web.DistributedCache上的Microsoft.Web.DistributedCache.DataCacheForwarderBase . <> c__DisplayClass311.b__30()中 . 在Microsoft.Web.DistributedCache.DataCacheRetryWrapper.PerformCacheOperation(Action action)中,在Microsoft.Web.DistributedCache.DataCacheForwarderBase.PerformCacheOperation [TResult](Func)在Microsoft.Web.DistributedCache.BlobBasedSessionStoreProvider上的Microsoft.Web.DistributedCache.DataCacheForwarderBase.Put(String key,Object value,TimeSpan timeout)的`1 func) System.Web.SessionState上的Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.SetAndReleaseItemExclusive(HttpContext上下文,String id,SessionStateStoreData项,Object lockId,Boolean newItem)处的.SetAndReleaseItemExclusive(HttpContextBase上下文,String id,SessionStateStoreData项,Object lockId,Boolean newItem) System.Web.HttpApplication.ExecuteStep上的System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()中的.SessionStateModule.OnReleaseState(Object source,EventArgs eventArgs)(IExecutionStep step,Boolean&completedSynchronously)

我想知道这些是否已经开始由于我们为我们的对象实现缓存,而在我们只使用服务进行会话状态之前 . 以下是我的缓存类 .

public static class AzureCacheHelper
{
    private static DataCacheFactory _factory;

    private static DataCache _cache;

    public static DataCacheFactory DataCacheFactory
    {
        get
        {

            if (_factory == null)
            {

                _factory = new DataCacheFactory();

            }

            return _factory;
        }
    }

    public static DataCache DataCache
    {
        get
        {
            if (_cache == null)
            {

                _cache = DataCacheFactory.GetDefaultCache();

            }
            return _cache;
        }
    }
}
public class AzureCache
{        
    public void Add(string key, object value, string cacheName = "default", List<string> tags = null)
    {
        try
        {
            FixedInterval _retryStrategy = new FixedInterval(3, TimeSpan.FromSeconds(1));
            RetryPolicy _retryPolicy = new RetryPolicy<CacheTransientErrorDetectionStrategy>(_retryStrategy);
            List<DataCacheTag> _tags = new List<DataCacheTag>();
            if (tags != null)
            {
                foreach (var tag in tags)
                    _tags.Add(new DataCacheTag(tag));
                _retryPolicy.ExecuteAction(() =>
                {
                    AzureCacheHelper.DataCache.Add(key, value, _tags.AsEnumerable(), "all");
                });
                return;
            }
            _retryPolicy.ExecuteAction(() =>
            {
                AzureCacheHelper.DataCache.Put(key, value);
            });
        }
        catch (Exception e)
        { }
    }

    public object Get(string key, string cacheName = "default")
    {
        try
        {
            FixedInterval _retryStrategy = new FixedInterval(3, TimeSpan.FromSeconds(1));
            RetryPolicy _retryPolicy = new RetryPolicy<CacheTransientErrorDetectionStrategy>(_retryStrategy);
            object obj = null;
            _retryPolicy.ExecuteAction(() =>
            {
                obj = AzureCacheHelper.DataCache.Get(key);
            });
            return obj;
        }
        catch (Exception e)
        {
            ILogService logService = ObjectFactory.GetInstance<ILogService>();
            logService.InsertLog(LogTypeEnum.Error, "Error in cache get", e);
            logService.SaveChanges();
            return null; 
        }
    }

    public void Remove(string key, string cacheName = "default")
    {
        try
        {
            FixedInterval _retryStrategy = new FixedInterval(3, TimeSpan.FromSeconds(1));
            RetryPolicy _retryPolicy = new RetryPolicy<CacheTransientErrorDetectionStrategy>(_retryStrategy);
            _retryPolicy.ExecuteAction(() =>
            {
                AzureCacheHelper.DataCache.Remove(key);
            });
        }
        catch (Exception e)
        {  }
    }

    public void RemoveByPattern(string pattern, string cacheName = "default")
    {
        try
        {
            FixedInterval _retryStrategy = new FixedInterval(3, TimeSpan.FromSeconds(1));
            RetryPolicy _retryPolicy = new RetryPolicy<CacheTransientErrorDetectionStrategy>(_retryStrategy);
            DataCacheTag tag = new DataCacheTag(pattern);
            _retryPolicy.ExecuteAction(() =>
            {
                //IEnumerable<KeyValuePair<string, object>> items = null;
                var items = AzureCacheHelper.DataCache.GetObjectsByTag(tag, "all");
                foreach (var item in items)
                    AzureCacheHelper.DataCache.Remove(item.Key);
            });
        }
        catch (Exception e)
        { }
    }
}

对此有任何帮助非常感谢 . 谢谢