本文整理汇总了C#中CacheItemPriority类的典型用法代码示例。如果您正苦于以下问题:C# CacheItemPriority类的具体用法?C# CacheItemPriority怎么用?C# CacheItemPriority使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CacheItemPriority类属于命名空间,在下文中一共展示了CacheItemPriority类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Insert
public static void Insert(string key, object value, CacheDependency dependency, TimeSpan timeframe, CacheItemPriority priority)
{
if (value != null)
{
_cache.Insert(key, value, dependency, DateTime.Now.Add(timeframe), Cache.NoSlidingExpiration, priority, null);
}
}
示例2: CacheItem
/// <summary>Costructor</summary>
/// <param name="value">Actual object to be stored in cache</param>
public CacheItem(object value)
{
_v = value;
_abs = Cache.NoAbsoluteExpiration;
_sld = Cache.NoSlidingExpiration;
_p = CacheItemPriority.Default;
}
示例3: SetPriority
/// <summary>
/// Sets the priority for keeping the cache entry in the cache during a memory pressure tokened cleanup.
/// </summary>
/// <param name="options"></param>
/// <param name="priority"></param>
public static MemoryCacheEntryOptions SetPriority(
this MemoryCacheEntryOptions options,
CacheItemPriority priority)
{
options.Priority = priority;
return options;
}
示例4: AddCommand
internal AddCommand(string key, byte[] value, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, short removeCallback, short updateCallback, Hashtable queryInfo, BitSet flagMap, string cacheId,EventDataFilter updateDataFilter,EventDataFilter removeDataFilter)
{
base.name = "AddCommand";
base.key = key;
_addCommand = new Alachisoft.NCache.Common.Protobuf.AddCommand();
if (absoluteExpiration != Cache.NoAbsoluteExpiration)
_addCommand.absExpiration = absoluteExpiration.Ticks;
if (slidingExpiration != Cache.NoSlidingExpiration)
_addCommand.sldExpiration = slidingExpiration.Ticks;
Alachisoft.NCache.Caching.UserBinaryObject ubObject = Alachisoft.NCache.Caching.UserBinaryObject.CreateUserBinaryObject(value);
_addCommand.key = key;
_addCommand.data.AddRange(ubObject.DataList);
_addCommand.requestId = base.RequestId;
_addCommand.updateCallbackId = updateCallback;
_addCommand.removeCallbackId = removeCallback;
_addCommand.priority = (int)priority;
_addCommand.flag = flagMap.Data;
_addCommand.updateDataFilter = (short)updateDataFilter;
_addCommand.removeDataFilter = (short)removeDataFilter;
// Changes made to send Queries, Tags and NamgedTags in a single object
ObjectQueryInfo objectQueryInfo = new ObjectQueryInfo();
if (queryInfo["query-info"] != null)
objectQueryInfo.queryInfo = ProtobufHelper.GetQueryInfoObj(queryInfo["query-info"] as Hashtable);
_addCommand.objectQueryInfo = objectQueryInfo;
}
示例5: CacheItemArgs
public CacheItemArgs(string key)
{
_CacheKey = key;
_CacheTimeOut = 20;
_CachePriority = CacheItemPriority.Default;
//_ParamList = new ArrayList();
}
示例6: InsertCommand
public InsertCommand(string key, byte[] value, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, short removeCallback, short updateCallback, Hashtable queryInfo, BitSet flagMap, object lockId, LockAccessType accessType, string cacheId, EventDataFilter updateCallbackFilter, EventDataFilter removeCallabackFilter)
{
base.name = "InsertCommand";
base.key = key;
_insertCommand = new Alachisoft.NCache.Common.Protobuf.InsertCommand();
_insertCommand.key = key;
Alachisoft.NCache.Caching.UserBinaryObject ubObject = UserBinaryObject.CreateUserBinaryObject(value);
_insertCommand.data.AddRange(ubObject.DataList);
_insertCommand.requestId = base.RequestId;
_insertCommand.removeCallbackId = removeCallback;
_insertCommand.updateCallbackId = updateCallback;
_insertCommand.updateDataFilter = (short)updateCallbackFilter;
_insertCommand.removeDataFilter = (short)removeCallabackFilter;
_insertCommand.priority = (int)priority;
_insertCommand.flag = flagMap.Data;
if(lockId != null) _insertCommand.lockId = lockId.ToString();
_insertCommand.lockAccessType = (int)accessType;
if (absoluteExpiration != Web.Caching.Cache.NoAbsoluteExpiration)
_insertCommand.absExpiration = absoluteExpiration.Ticks;
if (slidingExpiration != Web.Caching.Cache.NoSlidingExpiration)
_insertCommand.sldExpiration = slidingExpiration.Ticks;
ObjectQueryInfo objectQueryInfo = new ObjectQueryInfo();
if (queryInfo["query-info"] != null)
objectQueryInfo.queryInfo = ProtobufHelper.GetQueryInfoObj(queryInfo["query-info"] as Hashtable);
_insertCommand.objectQueryInfo = objectQueryInfo;
}
示例7: Insert
public static void Insert(string key, object obj, CacheDependency dep, int seconds, CacheItemPriority priority)
{
if (obj != null)
{
_cache.Insert(key, obj, dep, DateTime.Now.AddSeconds((double) (Factor * seconds)), TimeSpan.Zero, priority, null);
}
}
示例8: CacheItem
/// <summary>
/// Constructs a fully formed CacheItem. This constructor is to be used when restoring an existing
/// CacheItem from the backing store. As such, it does not generate its own Guid for this instance,
/// but allows the guid to be passed in, as read from the backing store.
/// </summary>
/// <param name="lastAccessedTime">Time this CacheItem last accessed by user.</param>
/// <param name="key">Key provided by the user for this cache item. May not be null.</param>
/// <param name="value">Value to be stored. May be null.</param>
/// <param name="scavengingPriority">Scavenging priority of CacheItem. See <see cref="CacheItemPriority" /> for values.</param>
/// <param name="refreshAction">Object supplied by caller that will be invoked upon expiration of the CacheItem. May be null.</param>
/// <param name="expirations">Param array of ICacheItemExpiration objects. May provide 0 or more of these.</param>
public CacheItem(DateTime lastAccessedTime, string key, object value, CacheItemPriority scavengingPriority, ICacheItemRefreshAction refreshAction, params ICacheItemExpiration[] expirations)
{
Initialize(key, value, refreshAction, scavengingPriority, expirations);
TouchedByUserAction(false, lastAccessedTime);
InitializeExpirations();
}
示例9: AddCache
/// <summary>
/// 建立定时不访问便移除的缓存
/// </summary>
public static object AddCache(string key, object value, TimeSpan slidingExpiration, CacheItemPriority priority)
{
if (HttpRuntime.Cache[key] == null && value != null)
return HttpRuntime.Cache.Add(key, value, null, Cache.NoAbsoluteExpiration, slidingExpiration, priority, null);
else
return null;
}
示例10: Insert
public void Insert(string key, object value, CacheDependency dependencies,
DateTime absoluteExpiration, TimeSpan slidingExpiration,
CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback)
{
_cache.Insert(key, value, dependencies, absoluteExpiration, slidingExpiration,
priority, onRemoveCallback);
}
示例11: CacheItem
public CacheItem(string key, object value, CacheItemPriority scavengingPriority,params ICacheItemExpiration[] expirations)
{
Initialize(key, value, scavengingPriority, expirations);
TouchedByUserAction(false);
InitializeExpirations();
}
示例12: CacheEntry
internal CacheEntry (Cache objManager, string strKey, object objItem,CacheDependency objDependency,
CacheItemRemovedCallback eventRemove, DateTime dtExpires, TimeSpan tsSpan,
long longMinHits, bool boolPublic, CacheItemPriority enumPriority )
{
if (boolPublic)
_enumFlags |= Flags.Public;
_strKey = strKey;
_objItem = objItem;
_objCache = objManager;
_onRemoved += eventRemove;
_enumPriority = enumPriority;
_ticksExpires = dtExpires.ToUniversalTime ().Ticks;
_ticksSlidingExpiration = tsSpan.Ticks;
// If we have a sliding expiration it overrides the absolute expiration (MS behavior)
// This is because sliding expiration causes the absolute expiration to be
// moved after each period, and the absolute expiration is the value used
// for all expiration calculations.
if (tsSpan.Ticks != Cache.NoSlidingExpiration.Ticks)
_ticksExpires = DateTime.UtcNow.AddTicks (_ticksSlidingExpiration).Ticks;
_objDependency = objDependency;
if (_objDependency != null)
// Add the entry to the cache dependency handler (we support multiple entries per handler)
_objDependency.Changed += new CacheDependencyChangedHandler (OnChanged);
_longMinHits = longMinHits;
}
示例13: Insert
public override void Insert(string cacheKey, object itemToCache, DNNCacheDependency dependency, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority,
CacheItemRemovedCallback onRemoveCallback)
{
//onRemoveCallback += ItemRemovedCallback;
//Call base class method to add obect to cache
base.Insert(cacheKey, itemToCache, dependency, absoluteExpiration, slidingExpiration, priority, onRemoveCallback);
}
示例14: RedisCacheEntry
public RedisCacheEntry(String key,
Object value,
DateTimeOffset absoluteExpiration,
TimeSpan slidingExpiration,
CacheItemPriority priority)
: this(key, value, absoluteExpiration, slidingExpiration, priority.ToString())
{
}
示例15: CachedLifetime
public static IExpressionRegistration CachedLifetime(this IExpressionRegistration registration, TimeSpan slidingExpiration, CacheDependency dependency = null, CacheItemPriority itemPriority = CacheItemPriority.Default, CacheItemRemovedCallback itemRemovedCallback = null)
{
if (registration == null)
throw new ArgumentNullException("registration");
registration.SetLifetime(new CachedLifetime(slidingExpiration, dependency, itemPriority, itemRemovedCallback));
return registration;
}