本文整理汇总了C#中CacheItemRemovedReason类的典型用法代码示例。如果您正苦于以下问题:C# CacheItemRemovedReason类的具体用法?C# CacheItemRemovedReason怎么用?C# CacheItemRemovedReason使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CacheItemRemovedReason类属于命名空间,在下文中一共展示了CacheItemRemovedReason类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RebuildFromCacheHit
/// <summary>
/// Called when the cache dependancy of a subdirectory of the root image folder is modified, created, or removed
/// </summary>
private static void RebuildFromCacheHit(string key, object value, CacheItemRemovedReason reason)
{
var data = (KeyValuePair<string, string>)value;
string cssPath = data.Key;
string path = data.Value;
switch (reason)
{
case CacheItemRemovedReason.DependencyChanged:
if (ProcessDirectory(cssPath, path, true))
{
// Add the current directory back into the cache
InsertItemIntoCache(cssPath, path);
}
break;
// Cache items will only be manually removed if they have to be rebuilt due to changes in a folder that they inherit settings from
case CacheItemRemovedReason.Removed:
if (ProcessDirectory(cssPath, path, false))
{
InsertItemIntoCache(cssPath, path);
}
break;
case CacheItemRemovedReason.Expired:
case CacheItemRemovedReason.Underused:
// Don't need to reprocess parameters, just re-insert the item into the cache
HttpRuntime.Cache.Insert(key, value, new CacheDependency(path), Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, RebuildFromCacheHit);
break;
default:
break;
}
return;
}
示例2: onRemove
//建立回调委托的一个实例
public void onRemove(string key, object val, CacheItemRemovedReason reason)
{
switch (reason)
{
case CacheItemRemovedReason.DependencyChanged:
break;
case CacheItemRemovedReason.Expired:
{
//CacheItemRemovedCallback callBack = new CacheItemRemovedCallback(this.onRemove);
//webCache.Insert(key, val, null, System.DateTime.Now.AddMinutes(TimeOut),
// System.Web.Caching.Cache.NoSlidingExpiration,
// System.Web.Caching.CacheItemPriority.High,
// callBack);
break;
}
case CacheItemRemovedReason.Removed:
{
break;
}
case CacheItemRemovedReason.Underused:
{
break;
}
default: break;
}
//如需要使用缓存日志,则需要使用下面代码
//myLogVisitor.WriteLog(this,key,val,reason);
}
示例3: OnVideoCacheCleared
private void OnVideoCacheCleared(string key, object value, CacheItemRemovedReason reason)
{
if (key.Equals("All"))
CacheAll();
else
CacheCategory(key);
}
示例4: CacheItemRemoved
public void CacheItemRemoved(string key, object value, CacheItemRemovedReason reason)
{
UserService.CheckActiveUsers();
// Neuen Task anlegen, damit dieser im nächsten Intervall wieder ausgeführt wird
AddTask(key, Convert.ToInt32(value));
}
示例5: RemovedCallback
//TOTEST: set breakpoint here
//Run solution and click AddItemToCache button
//Either click RemoveItemFromCache button OR wait 60+ seconds and see that this event is fired
public void RemovedCallback(string k, object v, CacheItemRemovedReason r)
{
itemRemoved = true;
reason = r;
//Callback cannot access placeholders in aspx file
//lblResult.Text = "RemovedCallback event raised. Reason: " + reason;
}
示例6: RefreshActionData
public RefreshActionData(ICacheItemRefreshAction refreshAction, string keyToRefresh, object removedData, CacheItemRemovedReason removalReason)
{
this.refreshAction = refreshAction;
this.keyToRefresh = keyToRefresh;
this.removalReason = removalReason;
this.removedData = removedData;
}
示例7: CacheItemRemoved
public void CacheItemRemoved(string k, object v, CacheItemRemovedReason r)
{
// do stuff here if it matches our taskname, like WebRequest
// re-add our task so it recurs
DateTime dt = DateTime.Now;
Clients.All.keepMeAlive();
var turnamentsStars = context.Turnaments.Where(x => x.StartTime <= dt && x.IsSeatAndGo == false && !x.isStarted).ToList();
foreach (var turnament in turnamentsStars)
{
turnament.isStarted = true;
context.SaveChanges();
for (int i = 0; i < turnament.Playes.Count / 2; i++)
{
var player1 = turnament.Playes[i];
var player2 = turnament.Playes[i + 1];
long gameId = DateTime.Now.Ticks;
int rows = turnament.SizeX;
int cols = turnament.SizeY;
AcceptUserInvite(player1.DeviceId, player2.DeviceId, rows.ToString(), cols.ToString(), turnament.Id);
//Clients.Client(player1.UserWebClientId).acceptInvite(player1.DeviceId, player2.DeviceId, rows, cols, gameId);
//Clients.Client(player2.UserWebClientId).acceptInvite(player1.DeviceId, player2.DeviceId, rows, cols, gameId);
}
}
int setNextTime = 60;
AddTask(k, setNextTime);
}
示例8: RefreshData
public static void RefreshData(String key, Object item,
CacheItemRemovedReason reason)
{
try
{
lock (_cache)
{
BusinessLogic.Parameter.Parameter par = new BusinessLogic.Parameter.Parameter();
DataSet.DSParameter ds = par.GetParamerter();
System.TimeSpan span = new TimeSpan(0, 0, 30, 20, 0);
//if( ds != null )
// _cache["data"] = ds;
_cache.Insert("data", ds, null,
Cache.NoAbsoluteExpiration, span,
CacheItemPriority.High,
new CacheItemRemovedCallback(RefreshData));
}
}
catch
{
}
}
示例9: PerformScheduledTasks
static void PerformScheduledTasks(string key, Object value, CacheItemRemovedReason reason)
{
try
{
MerchantTribe.Commerce.RequestContext context = new MerchantTribe.Commerce.RequestContext();
MerchantTribeApplication app = MerchantTribe.Commerce.MerchantTribeApplication.InstantiateForDataBase(context);
List<long> storeIds = app.ScheduleServices.QueuedTasks.ListStoresWithTasksToRun();
if (storeIds != null)
{
List<MerchantTribe.Commerce.Accounts.StoreDomainSnapshot> stores = app.AccountServices.Stores.FindDomainSnapshotsByIds(storeIds);
if (stores != null)
{
System.Threading.Tasks.Parallel.ForEach(stores, CallTasksOnStore);
//foreach (MerchantTribe.Commerce.Accounts.StoreDomainSnapshot snap in stores)
//{
// string storekey = System.Configuration.ConfigurationManager.AppSettings["storekey"];
// string rootUrl = snap.RootUrl();
// string destination = rootUrl + "scheduledtasks/" + storekey;
// MerchantTribe.Commerce.Utilities.WebForms.SendRequestByPost(destination, string.Empty);
//}
}
}
}
catch
{
// suppress error and schedule next run
}
ScheduleTaskTrigger();
}
示例10: OnCacheItemRemoved
private void OnCacheItemRemoved(string key, object value, CacheItemRemovedReason reason)
{
_onFileChanged(key);
// We need to register again to get the next notification
RegisterForNextNotification(key);
}
示例11: Signal
public void Signal(string key, object value, CacheItemRemovedReason reason)
{
var virtualPath = Convert.ToString(value);
var token = DetachToken(virtualPath);
if (token != null)
token.IsCurrent = false;
}
示例12: Hit
private static void Hit(string s, object o, CacheItemRemovedReason reason)
{
string path = ConfigurationManager.AppSettings["hitPath"];
WebClient request = new WebClient();
request.DownloadData(path);
}
示例13: RemovedCallback
/// <summary>
/// Called when object removed from cache
/// </summary>
/// <param name="k"></param>
/// <param name="v"></param>
/// <param name="r"></param>
public void RemovedCallback(String k, Object v, CacheItemRemovedReason r)
{
try {
File.Delete(fileName);
}
catch { /* nothing todo... */ }
}
示例14: 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 void CacheItemRemoved( string k, object v, CacheItemRemovedReason r )
{
try
{
if ( r == CacheItemRemovedReason.Expired )
{
// call a page on the site to keep IIS alive
string url = ConfigurationManager.AppSettings["BaseUrl"].ToString() + "KeepAlive.aspx";
WebRequest request = WebRequest.Create( url );
WebResponse response = request.GetResponse();
// add cache item again
AddCallBack();
// process the transaction queue
DrainTransactionQueue();
}
}
catch ( Exception ex )
{
try
{
EventLog.WriteEntry( "Rock", string.Format( "Exception in Global.CacheItemRemoved(): {0}", ex.Message ), EventLogEntryType.Error );
}
catch
{
// intentionally blank
}
}
}
示例15: CacheItemRemoved
public void CacheItemRemoved(string k, object v, CacheItemRemovedReason r)
{
// do stuff here if it matches our taskname, like WebRequest
// re-add our task so it recurs
ReportHelper.GenerateAndSendDailyPDFReport();
AddTask(k, Convert.ToInt32(v));
}