java - Concurrent map sorted by values with fast increment value operation -


I have a web application, where I need to keep track of "most popular" articles Most pages in the app (including article pages) display the "most popular" list in the sidebar, so these lists will be retrieved very often. On the other hand, articles are often visited many times (approximately 1/2 page visits are traveling to article pages).

What is the best way to keep track of visits and visits able articles to choose from? As I think, this should be a concurrent map article- ID-> Travel card is sorted by the values ​​(visit cans) and where I can quickly calculate the increase (and threadscreen) increase, and re-map the map. Should expect to sort.

For web applications, this will be the best location to store in the database. For a number of visits, create a database with the fields for the article ID and fields. Table table by the number of visits Whenever an article is viewed, enter or record existing records When you need to see the most popular list, So just ask the table.

The database is often the best answer to store data in a web application.

In this case, the database will be index based on the number of visits it makes a bit slow to insert and update, but the database is designed for this purpose, so it is very bad Will not done. Recovery of this data will always be super fast due to the index to maintain.


Comments