SoFunction
Updated on 2025-03-07

c# own cache usage method c# remove clean cache


/// <summary>
/// Get data cache
/// </summary>
/// <param name="CacheKey">key</param>
public static object GetCache(string CacheKey)
{
    objCache = ;
    return objCache[CacheKey];
}
/// <summary>
/// Set up data cache
/// </summary>
public static void SetCache(string CacheKey, object objObject)
{
    objCache = ;
    (CacheKey, objObject);
}
/// <summary>
/// Set up data cache
/// </summary>
public static void SetCache(string CacheKey, object objObject, TimeSpan Timeout)
{
    objCache = ;
    (CacheKey, objObject, null, , Timeout, , null);
}
/// <summary>
/// Set up data cache
/// </summary>
public static void SetCache(string CacheKey, object objObject, DateTime absoluteExpiration, TimeSpan slidingExpiration)
{
    objCache = ;
    (CacheKey, objObject, null, absoluteExpiration, slidingExpiration);
}
/// <summary>
/// Remove the specified data cache
/// </summary>
public static void RemoveAllCache(string CacheKey)
{
    _cache = ;
    _cache.Remove(CacheKey);
}
/// <summary>
/// Remove all caches
/// </summary>
public static void RemoveAllCache()
{
    _cache = ;
    IDictionaryEnumerator CacheEnum = _cache.GetEnumerator();
    while (())
    {
_cache.Remove(());
    }
}