• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CacheEntry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Intercept

        public void Intercept(IInvocation invocation)
        {
            var cacheKey = string.Format("{0}||{1}", invocation.Method.Name, invocation.Method.DeclaringType.Name);

            if (_cache.ContainsKey(cacheKey))
            {
                var entry = _cache[cacheKey];
                if (DateTime.Now < entry.Expiry)
                {
                    invocation.ReturnValue = entry.ReturnValue;
                    return;
                }
            }

            invocation.Proceed();
         
            // Can we cache this entry?
            if (invocation.MethodInvocationTarget.GetCustomAttributes(typeof (CacheAttribute), true).Length == 0) 
                return;
            
            var newEntry = new CacheEntry()
                               {
                                   Expiry = DateTime.Now.AddSeconds(5), 
                                   ReturnValue = invocation.ReturnValue
                               };
            _cache[cacheKey] = newEntry;
        }
开发者ID:PaulStovell,项目名称:presentations,代码行数:27,代码来源:CacheInterceptor.cs


示例2: GetData

        /// <summary>
        /// Returns a Matrix with the data for the TimeStep, Item
        /// TimeStep counts from 0, Item from 1.
        /// Lower left in Matrix is (0,0)
        /// </summary>
        /// <param name="TimeStep"></param>
        /// <param name="Item"></param>
        /// <param name="Layer"></param>
        /// <returns></returns>
        public Matrix GetData(int TimeStep, int Item)
        {
            CacheEntry cen;

              Dictionary<int, CacheEntry> _timeValues;

              if (!_bufferData.TryGetValue(Item, out _timeValues))
              {
            _timeValues = new Dictionary<int, CacheEntry>();
            _bufferData.Add(Item, _timeValues);
              }
              if (!_timeValues.TryGetValue(TimeStep, out cen))
              {
            ReadItemTimeStep(TimeStep, Item);
            Matrix _data = new Matrix(_numberOfRows, _numberOfColumns);
            int m = 0;
            for (int i = 0; i < _numberOfRows; i++)
              for (int j = 0; j < _numberOfColumns; j++)
              {
            _data[i, j] = dfsdata[m];
            m++;
              }
            cen = new CacheEntry(AbsoluteFileName, Item, TimeStep, _data);
            _timeValues.Add(TimeStep, cen);
            CheckBuffer();
              }
              else
            AccessList.Remove(cen);
              AccessList.AddLast(cen);
              return cen.Data;
        }
开发者ID:shobaravi,项目名称:mikeshewrapper,代码行数:40,代码来源:DFS2.cs


示例3: Id_ShouldReturnCorrectValue

		public void Id_ShouldReturnCorrectValue(
			[Frozen]Guid id,
			CacheEntry<object> sut)
		{
			//assert
			sut.Id.Should().Be(id);
		}
开发者ID:Galad,项目名称:Hanno,代码行数:7,代码来源:CacheEntryTests.cs


示例4: GetPrimePlatSellOrders

        public static async Task<long?> GetPrimePlatSellOrders(string primeName)
        {
            CacheEntry<long?> cacheItem;
            if (_marketCache.TryGetValue(primeName, out cacheItem))
            {
                if (!cacheItem.IsExpired(_expirationTimespan))
                {
                    return cacheItem.Value;
                }
            }

            var textInfo = new CultureInfo("en-US", false).TextInfo;

            var partName = textInfo.ToTitleCase(primeName.ToLower());

            if (_removeBPSuffixPhrases.Any(suffix => partName.EndsWith(suffix + " Blueprint")))
            {
                partName = partName.Replace(" Blueprint", "");
            }

            // Since Warframe.Market is still using the term Helmet instead of the new one, TODO: this might change
            partName = partName.Replace("Neuroptics", "Helmet");

            if (_fixedQueryStrings.ContainsKey(partName))
            {
                //Some of Warframe.Market's query strings are mangled (extra spaces, misspellings, words missing) fix them manually...
                partName = _fixedQueryStrings[partName];
            }

            string jsonData;
            using (var client = new WebClient())
            {
                var uri = new Uri(_baseUrl + Uri.EscapeDataString(partName));

                try
                {
                    jsonData = await client.DownloadStringTaskAsync(uri);

                    dynamic result = JsonConvert.DeserializeObject(jsonData);

                    // when the server responds anything that is not 200 (HTTP OK) don't bother doing something else
                    if (result.code != 200)
                    {
                        Debug.WriteLine($"Error with {partName}, Status Code: {result.code.Value}");
                        _marketCache[primeName] = new CacheEntry<long?>(null);
                        return null;
                    }

                    IEnumerable<dynamic> sellOrders = result.response.sell;
                    long? smallestPrice = sellOrders.Where(order => order.online_status).Min(order => order.price);

                    _marketCache[primeName] = new CacheEntry<long?>(smallestPrice);
                    return smallestPrice;
                }
                catch
                {
                    return null;
                }
            }            
        }
开发者ID:Xeio,项目名称:VoidRewardParser,代码行数:60,代码来源:PlatinumPrices.cs


示例5: Insert

		public bool Insert(Segment seg)
		{
			Debug.Assert(Exists(seg.SegmentID) == false);

			int pos = (int)(seg.SegmentID % m_size);

			CacheEntry head = m_data[pos];

			if (head == null)
				m_data[pos] = new CacheEntry(seg);
			else
			{
				while (head.Next != null &&head.Segment.SegmentID != seg.SegmentID)
				{
					head = head.Next;
				}
				if (head.Segment.SegmentID == seg.SegmentID)
					return false;
				else
				{
					head.Next = new CacheEntry(seg,null);
				}
			}

			m_count ++;
			return true;
		}
开发者ID:luanzhu,项目名称:OOD.NET,代码行数:27,代码来源:CacheHashtable.cs


示例6: Lookup

        public CacheEntry Lookup(string fullname)
        {
            string[] names = fullname.Split('\\');

            CacheEntry current = this;
            CacheEntry child = null;
            foreach (string entry in names)
            {
                if (current.Children == null)
                    current.Children = new Dictionary<string, CacheEntry>();

                if (current.Children.TryGetValue(entry, out child))
                {
                    current = child;
                }
                else
                {
                    CacheEntry cache = new CacheEntry(entry);
                    current.Children[entry] = cache;
                    cache.Parent = current;
                    current = cache;
                }
            }

            return current;
        }
开发者ID:mushuanli,项目名称:nekodrive,代码行数:26,代码来源:NFSCache.cs


示例7: CreateCacheEntry

        private CacheEntry CreateCacheEntry(Type type)
        {
            var encoderType = typeof(IFrameEncoder<>).MakeGenericType(type);

            // Func<object, Stream, object, Task> callback = (encoder, body, value) =>
            // { 
            //   return ((IStreamEncoder<T>)encoder).Encode(body, (T)value);
            // }

            var encoderParam = Expression.Parameter(typeof(object), "encoder");
            var bodyParam = Expression.Parameter(typeof(Stream), "body");
            var valueParam = Expression.Parameter(typeof(object), "value");

            var encoderCast = Expression.Convert(encoderParam, encoderType);
            var valueCast = Expression.Convert(valueParam, type);
            var encode = encoderType.GetMethod("Encode", BindingFlags.Public | BindingFlags.Instance);
            var encodeCall = Expression.Call(encoderCast, encode, bodyParam, valueCast);
            var lambda = Expression.Lambda<Func<object, Stream, object, Task>>(encodeCall, encoderParam, bodyParam, valueParam);

            var entry = new CacheEntry
            {
                Encode = lambda.Compile(),
                Encoder = _serviceProvider.GetRequiredService(encoderType)
            };

            return entry;
        }
开发者ID:davidfowl,项目名称:ServerStack,代码行数:27,代码来源:FrameOutput.cs


示例8: IndexAddTask

 public IndexAddTask(QueryIndexManager indexManager, object key, CacheEntry value, OperationContext operationContext)
 {
     _key = key;
     _entry = value;
     _indexManager = indexManager;
     _operationContext = operationContext;
 }
开发者ID:javithalion,项目名称:NCache,代码行数:7,代码来源:QueryIndexManager.cs


示例9: Cache

            public static void Cache(DiagnosticAnalyzer analyzer, object key, CacheEntry entry)
            {
                AssertKey(key);

                // add new cache entry
                var analyzerMap = s_map.GetOrAdd(analyzer, _ => new ConcurrentDictionary<object, CacheEntry>(concurrencyLevel: 2, capacity: 10));
                analyzerMap[key] = entry;
            }
开发者ID:TyOverby,项目名称:roslyn,代码行数:8,代码来源:DiagnosticIncrementalAnalyzer.InMemoryStorage.cs


示例10: Sanity

        public void Sanity()
        {
            var ceStr = new CacheEntry<string>(1, "3");

            Assert.AreEqual(DateTime.MinValue, ceStr.LastAccessed);
            Assert.AreEqual(1, ceStr.Key);
            Assert.AreEqual("3", ceStr.Val);
            Assert.IsTrue(ceStr.LastAccessed.AddMinutes(1) > DateTime.Now);
        }
开发者ID:dfugate,项目名称:code-interviews-vs,代码行数:9,代码来源:CacheEntryTest.cs


示例11: AddEntryAsync

 public async Task AddEntryAsync(CacheEntry entry, HttpResponseMessage response)
 {
     CacheEntryContainer cacheEntryContainer = GetOrCreateContainer(entry.Key);
     lock (syncRoot)
     {
         cacheEntryContainer.Entries.Add(entry);
         _responseCache[entry.VariantId] = response;
     }
 }
开发者ID:hapikit,项目名称:hapikit.net,代码行数:9,代码来源:InMemoryContentStore.cs


示例12: GetContentAsync

 public async Task<CacheContent> GetContentAsync(CacheEntry cacheEntry, string secondaryKey)
 {
     var inMemoryCacheEntry = _responseCache[cacheEntry.Key];
     if (inMemoryCacheEntry.Responses.ContainsKey(secondaryKey))
     {
         return await CloneAsync(inMemoryCacheEntry.Responses[secondaryKey]);
     }
     return null;
 }
开发者ID:paulcbetts,项目名称:Tavis.PrivateCache,代码行数:9,代码来源:InMemoryContentStore.cs


示例13: AsyncBroadcastCustomNotifyRemoval

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="listener"></param>
 /// <param name="data"></param>
 public AsyncBroadcastCustomNotifyRemoval(ClusterCacheBase parent, object key, CacheEntry entry, ItemRemoveReason reason, OperationContext operationContext, EventContext eventContext)
 {
     _parent = parent;
     _key = key;
     _entry = entry;
     _reason = reason;
     _operationContext = operationContext;
     _eventContext = eventContext;
 }
开发者ID:javithalion,项目名称:NCache,代码行数:14,代码来源:AsyncBroadcastCustomNotifyRemoval.cs


示例14: Create

 public static CacheEntry Create(object rawValue, DateTime createdAt, object options = null)
 {
     var opts = options.AsDictionary();
     var entry = new CacheEntry(null);
     entry.Value = rawValue;
     entry.CreatedAt = createdAt;
     entry.Compressed = opts["compressed"].AsBoolean();
     return entry;
 }
开发者ID:meadiagenic,项目名称:Stockpile,代码行数:9,代码来源:Entry.cs


示例15: GetInstanceOf

        public static object GetInstanceOf(Type providerType, object[] providerArgs)
        {
            CacheEntry entry = new CacheEntry(providerType, providerArgs);

            object instance = instances[entry];
            return instance == null
                ? instances[entry] = Reflect.Construct(providerType, providerArgs)
                : instance;
        }
开发者ID:ChrisMissal,项目名称:shouldly,代码行数:9,代码来源:ProviderCache.cs


示例16: ReturnStored

 public static CacheQueryResult ReturnStored(CacheEntry cacheEntry, HttpResponseMessage response)
 {
     HttpCache.UpdateAgeHeader(response);
     return new CacheQueryResult()
     {
         Status = CacheStatus.ReturnStored,
         SelectedEntry = cacheEntry,
         SelectedResponse = response
     };
 }
开发者ID:hapikit,项目名称:hapikit.net,代码行数:10,代码来源:CacheQueryResult.cs


示例17: addToCache

        private void addToCache(string fileName, CacheEntry entry)
        {
            _cache[fileName] = entry;
            calculateTotalSize();

            while (_totalBytes > _maxBytes)
            {
                deleteOldest();
            }
        }
开发者ID:panteras1000,项目名称:TheWriteStuff,代码行数:10,代码来源:FileCache.cs


示例18: PropagateCacheDependencies

 private void PropagateCacheDependencies(CacheEntry entry)
 {
     // Bubble up volatile tokens to parent context
     if (_accessor.Current != null)
     {
         foreach (var dependency in entry.Dependencies)
         {
             _accessor.Current.Monitor(dependency);
         }
     }
 }
开发者ID:elanwu123,项目名称:dnx,代码行数:11,代码来源:Cache.cs


示例19: Reload

		public void Reload (CacheEntry entry, object data, int width, int height)
		{
			lock (items) {
				lock (entry) {
					entry.Reload = true;
					entry.Width = width;
					entry.Height = height;
					entry.Data = data;
				}
				Monitor.Pulse (items);
			}
		}
开发者ID:guadalinex-archive,项目名称:guadalinex-v6,代码行数:12,代码来源:PixbufCache.cs


示例20: TestHashCode

        public void TestHashCode()
        {
            var entry1 = new CacheEntry<int, int>(1, 2);
            var entry2 = new CacheEntry<int, int>(1, 2);
            var entry3 = new CacheEntry<int, int>(1, 3);

            var set = new HashSet<object> {entry1};

            Assert.IsTrue(set.Contains(entry1));
            Assert.IsTrue(set.Contains(entry2));
            Assert.IsFalse(set.Contains(entry3));
        }
开发者ID:RazmikMkrtchyan,项目名称:ignite,代码行数:12,代码来源:CacheEntryTest.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CacheItem类代码示例发布时间:2022-05-24
下一篇:
C# CacheCommand类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap