T_Cyjb_Cache_SimplyCache_2 - CYJB/Cyjb GitHub Wiki

SimplyCache(TKey, TValue) 类

表示缓存个数不受限制的对象缓冲池。

继承层次

System.Object
  Cyjb.Cache.SimplyCache(TKey, TValue)
Namespace: Cyjb.Cache
Assembly: Cyjb (in Cyjb.dll) Version: 1.0.23+7750dd8e971297c5fa962a3bee37fb78f72793f6

语法

C#

public sealed class SimplyCache<TKey, TValue> : ICache<TKey, TValue>

类型参数

 

TKey
缓存对象的键的类型。
TValue
缓存对象的类型。
  The SimplyCache(TKey, TValue) type exposes the following members.

构造函数

 

名称 说明
公共方法 SimplyCache(TKey, TValue) 初始化 SimplyCache(TKey, TValue) 类的新实例。
  Back to Top

属性

 

名称 说明
公共属性 Count 获取实际包含在缓存中的对象数目。
  Back to Top

方法

 

名称 说明
公共方法 Add 将指定的键和对象添加到缓存中,无论键是否存在。
公共方法 Clear 清空缓存中的所有对象。
公共方法 Contains 确定缓存中是否包含指定的键。
公共方法 Equals Determines whether the specified object is equal to the current object. (继承自 Object。)
公共方法 GetHashCode Serves as the default hash function. (继承自 Object。)
公共方法 GetOrAdd(TKey, Func(TKey, TValue)) 从缓存中获取与指定的键关联的对象,如果不存在则将新对象添加到缓存中。
公共方法 GetOrAdd(TArg)(TKey, TArg, Func(TKey, TArg, TValue)) 从缓存中获取与指定的键关联的对象,如果不存在则将新对象添加到缓存中。
公共方法 GetType Gets the Type of the current instance. (继承自 Object。)
公共方法 Remove 从缓存中移除具有指定键的对象。
公共方法 ToString Returns a string that represents the current object. (继承自 Object。)
公共方法 TryGet 尝试从缓存中获取与指定的键关联的对象。
  Back to Top

Remarks

该类仅仅是 ConcurrentDictionary(TKey, TValue) 类的一个简单包装。 缓存的对象数量会一直增长下去,通常应仅作为测试使用或用于缓存生成的代价非常大的对象。

参见

Reference

Cyjb.Cache 命名空间

⚠️ **GitHub.com Fallback** ⚠️