server/aspnetapp/Helper/ListCache.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;

namespace aspnetapp.Helper
{
    /// <summary>
    /// BlockingCollection队列
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class ListCache<T> where T : class
    {
        private static ConcurrentDictionary<string, T> Colls;
        public ListCache()
        {

        }
        public static bool IsComleted()
        {
            if (Colls == null)
            {
                return true;
            }
            if (Colls != null && Colls.IsEmpty)
            {
                return true;
            }
            return false;
        }
        public static bool HasEle()
        {
            if (Colls != null && Colls.Count > 0)
            {
                return true;
            }
            return false;
        }

        public static bool AddOrUpdate(string key, T msg)
        {
            if (Colls == null)
            {
                Colls = new ConcurrentDictionary<string, T>();
            }
            if (!Colls.Any(s => s.Key == key))
            {
                Colls.AddOrUpdate(key, msg, (key, value) => value);
            }
            return true;
        }
        public static bool AnyEle(string key)
        {
            if (Colls == null)
            {
                Colls = new ConcurrentDictionary<string, T>();
            }
            return Colls.ContainsKey(key);
        }
        public static T Get(string key)
        {
后面还有 41 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。