C
C#3y ago
Gladiator

❔ Using concurrent collections to add or remove elements for in-memory collections (server)?

Should we use concurrent collections to add/remove elements to/from in-memory collections in asp.net? For example adding/removing players in online player list
7 Replies
Landan
Landan3y ago
You can use a hashset. Or a concurrent bag If your usecase is open to allow for more than in-memory context, you might look into using an external source of truth behind an event queue to handle operations which could execute out of sync, then pull the absolute context where you need it.
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Landan
Landan3y ago
In-memory may indicate they have an implementation for quick lookups or something for low latency solutions
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Gladiator
GladiatorOP3y ago
Yes and my concern is thread safe Because list or dictionary is not thread safe and because it is server side (asp.net multi thread env), it can cause problems. I would like to know if you want to cache it in memory, do you use concurrent collections? You mean something like Redis? yes, you are right but if you want to use only .Net collections to keep data which can be added/removed
Landan
Landan3y ago
No, CQRS. It would be an out of band sort of system, not confined to your single dotnet process.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server