/// <summary>
 /// 添加缓存项
 /// </summary>
 /// <typeparam name="TKey"></typeparam>
 /// <typeparam name="TValue"></typeparam>
 /// <param name="memoryCache"></param>
 /// <param name="key"></param>
 /// <param name="value"></param>
 public static void Add <TKey, TValue>(this IBoundedMemoryCache <TKey, TValue> memoryCache, TKey key, TValue value) where TValue : class
 {
     memoryCache.Add(new(key, value, null));
 }
 /// <summary>
 /// 添加缓存项
 /// </summary>
 /// <typeparam name="TKey"></typeparam>
 /// <typeparam name="TValue"></typeparam>
 /// <param name="memoryCache"></param>
 /// <param name="key"></param>
 /// <param name="value"></param>
 /// <param name="entryRemovingCallback"></param>
 public static void Add <TKey, TValue>(this IBoundedMemoryCache <TKey, TValue> memoryCache, TKey key, TValue value, CacheEntryRemovingCallback <TKey, TValue> entryRemovingCallback) where TValue : class
 {
     memoryCache.Add(new(key, value, entryRemovingCallback));
 }
示例#3
0
 /// <summary>
 /// <inheritdoc cref="LRUHotDataCache"/>
 /// </summary>
 /// <param name="capacity">容量</param>
 public LRUHotDataCache(int capacity)
 {
     _boundedMemoryCache = BoundedMemoryCache.CreateLRU <string, ResponseCacheEntry>(capacity);
 }