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


C# CacheEntry.UpdateLastModifiedTime方法代码示例

本文整理汇总了C#中CacheEntry.UpdateLastModifiedTime方法的典型用法代码示例。如果您正苦于以下问题:C# CacheEntry.UpdateLastModifiedTime方法的具体用法?C# CacheEntry.UpdateLastModifiedTime怎么用?C# CacheEntry.UpdateLastModifiedTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CacheEntry的用法示例。


在下文中一共展示了CacheEntry.UpdateLastModifiedTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InsertInternal

        /// <summary>
        /// Adds a pair of key and value to the cache. If the specified key already exists 
        /// in the cache; it is updated, otherwise a new item is added to the cache.
        /// </summary>
        /// <param name="key">key of the entry.</param>
        /// <param name="cacheEntry">the cache entry.</param>
        /// <returns>returns the result of operation.</returns>
        internal override CacheInsResult InsertInternal(object key, CacheEntry cacheEntry, bool isUserOperation, CacheEntry oldEntry, OperationContext operationContext)
        {
            if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("LocalCache.Insert", "");

            if (_cacheStore == null)
                throw new InvalidOperationException();

			if (cacheEntry.EvictionHint is PriorityEvictionHint)
				cacheEntry.Priority = ((PriorityEvictionHint)cacheEntry.EvictionHint).Priority;

            if (_evictionPolicy != null)
            {
                cacheEntry.EvictionHint = _evictionPolicy.CompatibleHint(cacheEntry.EvictionHint);
            }

            EvictionHint peEvh = oldEntry == null ? null : oldEntry.EvictionHint;

            //+ [email protected]: No Need to insert Eviction if Eviction is turned off it will reduce cache-entry overhead

            if (_evictionPolicy == null)
                cacheEntry.EvictionHint = null;
            
            //+ [email protected]

            StoreInsResult result = _cacheStore.Insert(key, cacheEntry, !isUserOperation);
            // Operation completed!            
            if (result == StoreInsResult.Success || result == StoreInsResult.SuccessNearEviction)
            {
                if (_evictionPolicy != null)
                    _evictionPolicy.Notify(key, null, cacheEntry.EvictionHint);
            }
            else if (result == StoreInsResult.SuccessOverwrite || result == StoreInsResult.SuccessOverwriteNearEviction)
            {
                //alam:
                //update the cache item last modifeid time...
                cacheEntry.UpdateLastModifiedTime(oldEntry);

                if (_evictionPolicy != null)
                    _evictionPolicy.Notify(key, peEvh, cacheEntry.EvictionHint);
            }
            if (result == StoreInsResult.NotEnoughSpace && !_notifyCacheFull)
            {
                _notifyCacheFull = true;
                _context.NCacheLog.Error("LocalCache.InsertInternal", "The cache is full and not enough items could be evicted.");
            }

            if (_context.PerfStatsColl != null)
            {
                if (_evictionPolicy != null)
                    _context.PerfStatsColl.SetEvictionIndexSize((long)_evictionPolicy.IndexInMemorySize);

                if (_context.ExpiryMgr != null)
                    _context.PerfStatsColl.SetExpirationIndexSize((long)_context.ExpiryMgr.IndexInMemorySize);
            }

            switch (result)
            {
                case StoreInsResult.Success: return CacheInsResult.Success;
                case StoreInsResult.SuccessOverwrite: return CacheInsResult.SuccessOverwrite;
                case StoreInsResult.NotEnoughSpace: return CacheInsResult.NeedsEviction;
                case StoreInsResult.SuccessNearEviction: return CacheInsResult.SuccessNearEvicition;
                case StoreInsResult.SuccessOverwriteNearEviction: return CacheInsResult.SuccessOverwriteNearEviction;
            }
            return CacheInsResult.Failure;
        }
开发者ID:christrotter,项目名称:NCache,代码行数:72,代码来源:LocalCache.cs


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