本文整理汇总了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 );
}
}
示例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 );
}
}