using System.Collections.Concurrent; namespace HybirdFrameworkDriver.Common; public class MsgCache { private readonly ConcurrentDictionary _dictionary = new(); private static readonly string MsgKey = "msg_"; public void Add(string key, dynamic value) { _dictionary[key] = value; } public bool TryGet(string key, out dynamic? value) { return _dictionary.TryGetValue(key, out value); } public void Remove(string key) { _dictionary.Remove(key, out var value); } public void AddByMsgId(int key, dynamic value) { _dictionary[MsgKey + key] = value; } public bool TryGetMsgId(int key, out dynamic? value) { return _dictionary.TryGetValue(MsgKey + key, out value); } public void RemoveMsgId(int key) { _dictionary.Remove(MsgKey + key, out var value); } }