❔ 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
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•3y ago
Message Not Public
Sign In & Join Server To View
In-memory may indicate they have an implementation for quick lookups or something for low latency solutions
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
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
No, CQRS.
It would be an out of band sort of system, not confined to your single dotnet process.
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.