I have a system running Coldfusion8/MySQL 5.0.88.
On some pages I need to pre-query parameters based on (logged in) users. For example, the site has a product search, which only allows to search products from sellers that authorized the user (allow-list).
Right now, when the user goes to the products page, I’m building the allow-list to display sellers. When the user triggers a product search, I invoke a search.cfc, which again builds the allow-list to perform the search. On another page, the user can lock/unlock sellers, so the list may change regularly.
Question:
Should I store the allow-list to the Session to have it available everywhere and not have to requery the database all the time? The list can be quite long (13-digit ID, comma separated). WOuld I need a Session.rebuild = true/false parameter to indicate, when to rebuild and not take the current Session value (after updating). Also will query caching make any sense if the query is identical, but on separate pages?
Thanks for some thoughts.
As long as the values stored in the session are not the security that protects them, that’s fine.
Query caching is based on the query being sent to the server, if it is identical it should not even touch the db, but get it from memory, effectively doing what your suggesting.