I am trying to cache a SQL Stored Procedure with multiple results sets by making use of the SQLCacheDependency class. The first three queries in the stored procedure are queries that are general to all the users on the website, and the fourth retrieves data filtered by the user name.
Since the fourth query in the stored procedure is filtered by the user name, does this mean that the SQLCacheDependency class will remove all the result sets from the Cache each time that another user executes it, or does it mean that it will hit the database to get the results of the fourth query in the stored procedure, and retrieve the results of the first 3 queries from the cache?
Thanks in advance
Since the Application Cache is global (i.e. the same cache is used for all users), what will probably happen is that the first users' results will be cached and served up for all subsequent users. Obviously not the outcome that you want. From the SQLCacheDependency documentation:
You should probably separate all 3 of the first queries, cache them independently, and not cache the 4th. Caching is really intended to amortize the cost of an expensive operation (in this case a SQL query) across many users. If you want to store something that is user-specific, that's what Session, Cookies, and ViewState are for.