一款简单易用的基础网络通讯组件库。

MemoryCacheTKey, TValue

一个简单的内存缓存

Definition

命名空间: TouchSocket.Core
程序集: TouchSocket.Core (在 TouchSocket.Core.dll 中) 版本:3.0.0+ccaf96084d09f972257496d1dd63b8ba3c1e44f0
C#
public class MemoryCache<TKey, TValue> : IEnumerable<ICacheEntry<TKey, TValue>>, 
	IEnumerable, ICache<TKey, TValue>, ICacheAsync<TKey, TValue>
Inheritance
Object    MemoryCacheTKey, TValue
Implements
IEnumerableICacheEntryTKey, TValue, IEnumerable, ICacheTKey, TValue, ICacheAsyncTKey, TValue

类型参数

TKey

[缺少 "T:TouchSocket.Core.MemoryCache`2" 的 <typeparam name="TKey"/> 文档]

TValue

[缺少 "T:TouchSocket.Core.MemoryCache`2" 的 <typeparam name="TValue"/> 文档]

构造函数

MemoryCacheTKey, TValue 一个简单的内存缓存

属性

Remove 当每个元素超时被移除时触发。

方法

AddCache 添加缓存。当缓存存在时,不会添加成功。
AddCacheAsync 添加缓存。当缓存存在时,不会添加成功。
ClearCache 清空所有缓存
ClearCacheAsync 清空所有缓存
ContainsCache 判断缓存是否存在,且在生命周期内。
ContainsCacheAsync 异步判断指定键的缓存是否存在且在生命周期内。
EqualsDetermines whether the specified object is equal to the current object.
(继承自 Object。)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(继承自 Object。)
GetCache 获取指定键的缓存。
GetCacheAsync 异步获取指定键的缓存条目。
GetEnumeratorReturns an enumerator that iterates through the collection.
GetHashCodeServes as the default hash function.
(继承自 Object。)
GetTypeGets the Type of the current instance.
(继承自 Object。)
MemberwiseCloneCreates a shallow copy of the current Object.
(继承自 Object。)
RemoveCache(TKey) 移除指定键的缓存。
RemoveCache(TKey, ICacheEntryTKey, TValue) 
RemoveCacheAsync 异步移除缓存项。
SetCache 设置缓存,不管缓存存不存在,都会添加。
SetCacheAsync 设置缓存,不管缓存存不存在,都会添加。
ToStringReturns a string that represents the current object.
(继承自 Object。)

扩展方法

ForEachICacheEntryTKey, TValue 循环遍历每个元素,执行Action动作
(由 CollectionsExtension 定义。)
ForEachAsyncICacheEntryTKey, TValue 循环遍历每个元素,执行异步动作
(由 CollectionsExtension 定义。)
Map
(由 Mapper 定义。)
Map
(由 Mapper 定义。)
MapTTarget
(由 Mapper 定义。)
MapListICacheEntryTKey, TValue, T1
(由 Mapper 定义。)
ToJsonString 转换为Json
(由 SerializeConvert 定义。)

显式接口实现

IEnumerableGetEnumeratorReturns an enumerator that iterates through a collection.

参见