当前位置: 首页>>代码示例>>C#>>正文


C# CacheItemRemovedReason.ConvertToString方法代码示例

本文整理汇总了C#中CacheItemRemovedReason.ConvertToString方法的典型用法代码示例。如果您正苦于以下问题:C# CacheItemRemovedReason.ConvertToString方法的具体用法?C# CacheItemRemovedReason.ConvertToString怎么用?C# CacheItemRemovedReason.ConvertToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CacheItemRemovedReason的用法示例。


在下文中一共展示了CacheItemRemovedReason.ConvertToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CacheItemRemoved

        /// <summary>
        /// Caches the item removed.
        /// </summary>
        /// <param name="k">The k.</param>
        /// <param name="v">The v.</param>
        /// <param name="r">The r.</param>
        public static void CacheItemRemoved( string k, object v, CacheItemRemovedReason r )
        {
            try
            {
                if ( r == CacheItemRemovedReason.Expired )
                {
                    // Process the transaction queue on another thread
                    Task.Run( () => DrainTransactionQueue() );

                    // add cache item again
                    AddCallBack();

                    // call a page on the site to keep IIS alive
                    if ( !string.IsNullOrWhiteSpace( Global.BaseUrl ) )
                    {
                        string url = Global.BaseUrl + "KeepAlive.aspx";
                        WebRequest request = WebRequest.Create( url );
                        WebResponse response = request.GetResponse();
                    }
                }
                else
                {
                    if ( r != CacheItemRemovedReason.Removed )
                    {
                        throw new Exception(
                            string.Format( "The IISCallBack cache object was removed without expiring.  Removed Reason: {0}",
                                r.ConvertToString() ) );
                    }
                }
            }
            catch ( Exception ex )
            {
                LogError( ex, null );
            }
        }
开发者ID:Ganon11,项目名称:Rock,代码行数:41,代码来源:Global.asax.cs

示例2: CacheItemRemoved

        /// <summary>
        /// Caches the item removed.
        /// </summary>
        /// <param name="k">The k.</param>
        /// <param name="v">The v.</param>
        /// <param name="r">The r.</param>
        public static void CacheItemRemoved( string k, object v, CacheItemRemovedReason r )
        {
            try
            {
                if ( r == CacheItemRemovedReason.Expired )
                {
                    // Process the transaction queue on another thread
                    Task.Run( () => DrainTransactionQueue() );

                    // add cache item again
                    AddCallBack();

                    var keepAliveUrl = GlobalAttributesCache.Value( "KeepAliveUrl" );
                    if ( string.IsNullOrWhiteSpace( keepAliveUrl ) )
                    {
                        keepAliveUrl = GlobalAttributesCache.Value( "InternalApplicationRoot" ) ?? string.Empty;
                        keepAliveUrl = keepAliveUrl.EnsureTrailingForwardslash() + "KeepAlive.aspx";
                    }

                    // call a page on the site to keep IIS alive
                    if ( !string.IsNullOrWhiteSpace( keepAliveUrl ) )
                    {
                        try
                        {
                            WebRequest request = WebRequest.Create( keepAliveUrl );
                            WebResponse response = request.GetResponse();
                        }
                        catch ( Exception ex )
                        {
                            LogError( new Exception( "Error doing KeepAlive request.", ex ), null );
                        }
                    }
                }
                else
                {
                    if ( r != CacheItemRemovedReason.Removed )
                    {
                        throw new Exception(
                            string.Format( "The IISCallBack cache object was removed without expiring.  Removed Reason: {0}",
                                r.ConvertToString() ) );
                    }
                }
            }
            catch ( Exception ex )
            {
                LogError( ex, null );
            }
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:54,代码来源:Global.asax.cs


注:本文中的CacheItemRemovedReason.ConvertToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。