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


C# CacheItem.GetExpirations方法代码示例

本文整理汇总了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);
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:32,代码来源:DataBackingStore.cs

示例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);
 }
开发者ID:wuyingyou,项目名称:uniframework,代码行数:13,代码来源:IsolatedStorageCacheItem.cs

示例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);
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:10,代码来源:CacheItemFixture.cs


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