Static List <User> VS DataBase for online users in Asp.Net?

I am creating an ASP.Net MVC "kinda Game" application, which has a lot to do with online users .

I made an Ajax request that each ran "10s"for some Actionto keep the user online when he keeps the site open. this Action update is LastActivityDate for this User- ((in static list and database)).


So the question is:

  • Is it better to store online users in a static list and write code when a user logs in to add him to this list, and then continue to manage this list every time "10s"to drive offline users.
  • Or it is best to download online users from the database whenever I want OnlineUsers.


Note: I am using the technique from this SO QUESTION to periodically perform tasks such as re-managing the static OnlineUsers list.

+3
source share
3 answers

-, List<User> , Dictionary<int,User>, , . -, , , , . , (, ) . , persistence , , , ​​ .

+2

, , Cache. , , , -, .

+2

, . . , , . -. , ? , , ?

Thus, database usage is inevitable. However, you can static region as a temporary cache, but you cannot rely on it.

+1
source

Source: https://habr.com/ru/post/1795071/


All Articles