本文整理汇总了C#中CacheItem.GetExpirations方法的典型用法代码示例。如果您正苦于以下问题:C# CacheItem.GetExpirations方法的具体用法?C# CacheItem.GetExpirations怎么用?C# CacheItem.GetExpirations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CacheItem
的用法示例。
在下文中一共展示了CacheItem.GetExpirations方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddNewItem
/// <summary>
/// Adds new item to persistence store
/// </summary>
/// <param name="storageKey">Unique key for storage item.</param>
/// <param name="newItem">Item to be added to cache. May not be null.</param>
protected override void AddNewItem(int storageKey,
CacheItem newItem)
{
string key = newItem.Key;
byte[] valueBytes = SerializationUtility.ToBytes(newItem.Value);
if (encryptionProvider != null)
{
valueBytes = encryptionProvider.Encrypt(valueBytes);
}
byte[] expirationBytes = SerializationUtility.ToBytes(newItem.GetExpirations());
byte[] refreshActionBytes = SerializationUtility.ToBytes(newItem.RefreshAction);
CacheItemPriority scavengingPriority = newItem.ScavengingPriority;
DateTime lastAccessedTime = newItem.LastAccessedTime;
DbCommand insertCommand = database.GetStoredProcCommand("AddItem");
database.AddInParameter(insertCommand, "@partitionName", DbType.String, partitionName);
database.AddInParameter(insertCommand, "@storageKey", DbType.Int32, storageKey);
database.AddInParameter(insertCommand, "@key", DbType.String, key);
database.AddInParameter(insertCommand, "@value", DbType.Binary, valueBytes);
database.AddInParameter(insertCommand, "@expirations", DbType.Binary, expirationBytes);
database.AddInParameter(insertCommand, "@refreshAction", DbType.Binary, refreshActionBytes);
database.AddInParameter(insertCommand, "@scavengingPriority", DbType.Int32, scavengingPriority);
database.AddInParameter(insertCommand, "@lastAccessedTime", DbType.DateTime, lastAccessedTime);
database.ExecuteNonQuery(insertCommand);
}
示例2: Store
/// <summary>
/// Stores specified CacheItem into IsolatedStorage at location specified in constructor
/// </summary>
/// <param name="itemToStore">The <see cref="CacheItem"/> to store.</param>
public void Store(CacheItem itemToStore)
{
keyField.Write(itemToStore.Key, false);
valueField.Write(itemToStore.Value, true);
scavengingPriorityField.Write(itemToStore.ScavengingPriority, false);
refreshActionField.Write(itemToStore.RefreshAction, false);
expirationsField.Write(itemToStore.GetExpirations(), false);
lastAccessedField.Write(itemToStore.LastAccessedTime, false);
}
示例3: CtorForLoadingInitializesExpirationsToMatchLastAccessedTime
public void CtorForLoadingInitializesExpirationsToMatchLastAccessedTime()
{
DateTime historicalTimestamp = DateTime.Now - TimeSpan.FromHours(1.0);
CacheItem item = new CacheItem(historicalTimestamp, "foo", "bar", CacheItemPriority.NotRemovable, null,
new SlidingTime(TimeSpan.FromHours(17.0), DateTime.Now));
ICacheItemExpiration[] expirations = item.GetExpirations();
SlidingTime expiration = expirations[0] as SlidingTime;
Assert.AreEqual(historicalTimestamp, expiration.TimeLastUsed);
}