I have an ASP.Net MVC 5 website. One of my controllers has a Search
action which searches the list of shops in the database.
I want to somehow keep track of latest search queries and show them to the users in another page. What comes to my mind is:
- Most straightforward way would be to save the queries in the database in the search action: I think it's not a good idea to hit the database for every single query.
- Saving the log for the search action and then parsing it and showing it to the user. It seems a little dirty to me!
- Save the queries in the cache and push them every couple of seconds or minutes to the database. This seems like the best option for me. Currently I'm using this for page hits. I increment the page's hit every time, save it to the cache and save the result to the DB.
Is there a better way? Which approach you'd suggest?