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


C# MemoryCache.GetEntry方法代码示例

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


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

示例1: InitDisposableMembers

 private void InitDisposableMembers(MemoryCache cache)
 {
     bool flag = true;
     try
     {
         bool hasChanged = false;
         string str = null;
         this._dependencies = new List<MemoryCacheEntry>(this._keys.Count);
         if (this._keys.Count == 1)
         {
             string key = this._keys[0];
             MemoryCacheEntry entry = cache.GetEntry(key);
             DateTime utcCreated = DATETIME_MINVALUE_UTC;
             this.StartMonitoring(cache, entry, ref hasChanged, ref utcCreated);
             str = key + utcCreated.Ticks.ToString("X", CultureInfo.InvariantCulture);
             this._lastModified = utcCreated;
         }
         else
         {
             int capacity = 0;
             foreach (string str3 in this._keys)
             {
                 capacity += str3.Length + 0x10;
             }
             StringBuilder builder = new StringBuilder(capacity);
             foreach (string str4 in this._keys)
             {
                 MemoryCacheEntry entry2 = cache.GetEntry(str4);
                 DateTime time2 = DATETIME_MINVALUE_UTC;
                 this.StartMonitoring(cache, entry2, ref hasChanged, ref time2);
                 builder.Append(str4);
                 builder.Append(time2.Ticks.ToString("X", CultureInfo.InvariantCulture));
                 if (time2 > this._lastModified)
                 {
                     this._lastModified = time2;
                 }
             }
             str = builder.ToString();
         }
         this._uniqueId = str;
         if (hasChanged)
         {
             base.OnChanged(null);
         }
         flag = false;
     }
     finally
     {
         base.InitializationComplete();
         if (flag)
         {
             base.Dispose();
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:55,代码来源:MemoryCacheEntryChangeMonitor.cs

示例2: MemoryCacheEntryChangeMonitor

        private MemoryCacheEntryChangeMonitor() {} // hide default .ctor

        private void InitDisposableMembers(MemoryCache cache) {
            bool dispose = true;
            try {
                bool hasChanged = false;
                string uniqueId = null;
                _dependencies = new List<MemoryCacheEntry>(_keys.Count);
                if (_keys.Count == 1) {
                    string k = _keys[0];
                    MemoryCacheEntry entry = cache.GetEntry(k);
                    DateTime utcCreated = DATETIME_MINVALUE_UTC;
                    StartMonitoring(cache, entry, ref hasChanged, ref utcCreated);
                    uniqueId = k + utcCreated.Ticks.ToString("X", CultureInfo.InvariantCulture);
                    _lastModified = utcCreated;
                }
                else {
                    int capacity = 0;
                    foreach (string key in _keys) {
                        capacity += key.Length + MAX_CHAR_COUNT_OF_LONG_CONVERTED_TO_HEXADECIMAL_STRING;
                    }
                    StringBuilder sb = new StringBuilder(capacity);
                    foreach (string key in _keys) {
                        MemoryCacheEntry entry = cache.GetEntry(key);
                        DateTime utcCreated = DATETIME_MINVALUE_UTC;
                        StartMonitoring(cache, entry, ref hasChanged, ref utcCreated);
                        sb.Append(key);
                        sb.Append(utcCreated.Ticks.ToString("X", CultureInfo.InvariantCulture));
                        if (utcCreated > _lastModified) {
                            _lastModified = utcCreated;
                        }
                    }
                    uniqueId = sb.ToString();
                }
                _uniqueId = uniqueId;
                if (hasChanged) {
                    OnChanged(null);
                }
                dispose = false;
            }
            finally {
                InitializationComplete();
                if (dispose) {
                    Dispose();
                }                
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:47,代码来源:MemoryCacheEntryChangeMonitor.cs

示例3: MemoryCacheEntryChangeMonitor

		public MemoryCacheEntryChangeMonitor (MemoryCache owner, IEnumerable <string> keys)
		{
			this.owner = owner;
			this.lastModified = DateTimeOffset.MinValue;

			MemoryCacheEntry mce;
			var sb = new StringBuilder ();
			var list = new List <string> ();
			foreach (string key in keys) {
				mce = owner.GetEntry (key);
				list.Add (key);
#if true
				// LAMESPEC: this is what's happening
				DateTimeOffset modtime;
				modtime = new DateTimeOffset (mce != null ? mce.LastModified : DateTime.MinValue);
				if (this.lastModified < modtime)
					this.lastModified = modtime;
#else
				// LAMESPEC: this is what is supposed to be happening
				if (mce == null) {
					OnChanged (null);
					sb.Append ("{0}{1:x}", key, DateTime.MinValue.Ticks);
					continue;
				}
				
				DateTime modtime = mce.LastModified;
				if (this.lastModtime < modtime)
					this.lastModtime = new DateTimeOffset (modtime);
#endif
				sb.AppendFormat ("{0}{1:X}", key, modtime.Ticks);
			}
			this.uniqueId = sb.ToString ();
			this.cacheKeys = new ReadOnlyCollection <string> (list);

			// TODO: hook up to change events on MemoryCache
		}
开发者ID:stabbylambda,项目名称:mono,代码行数:36,代码来源:MemoryCacheEntryChangeMonitor.cs


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