![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Also while I have your attention, what is the accepted way to namespace your cache entries? have a look at MSDN for naming conventions. I do not particularly adhere to |
|
Hi all, I am looking for some advice on how to implement a caching solution for use in my asp.net app. I have a function that returns a simple true or false, but to get the answer needs to execute appox 20 queries to the database. This function gets called a lot so I want to store the result in a cache. The problem is that the function is dependent on three parameters two of which are indexes of lists stored in the database, a change to any of these lists invalidates the function's cached results. What I need to implement is a cache where I can invalidate all cache items that have a dependency on a certain list index. At the moment, I have a database table which looks like this MembershipListID, AccessListID, OperationID, result, timestamp Everytime this function is called, I check to see if there is a result in the cache table, if the is I use it otherwise I do the work and an entry to the cache table. If the value of one of the lists changes I issue a delete for all records that use that list ID. Now I would like to move this to the ASP.NET cache for a bit more speed, and ease of management but am not sure how to. My best idea at the moment is to create dummy cache entries for each of the list indexes and then create a cache dependency on these keys for each result that goes into the cache, something like this. MembershipListID = 4 AccessListID = 8 OperationID = 3 Result = true So I would add the following place holders for creating cache dependencies MLID#4 ALID#8 I would then add another cache item with the key FR#4#8#3 with the value true and cache dependencies on MLID#4 and ALID#8 When one of the lists changes, I would remove the place holder key from the cache, for example MLID#4 and that would remove all the function results dependant on it. Is this the best way to solve something like this? Also while I have your attention, what is the accepted way to namespace your cache entries? I don't want my cache entries to get confused with another assemleblies data, so what do I do? Pre/post fix the key with the assembly name or public key? Thanks Stephen |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Hi all, I am looking for some advice on how to implement a caching solution for use in my asp.net app. I have a function that returns a simple true or false, but to get the answer needs to execute appox 20 queries to the database. This function gets called a lot so I want to store the result in a cache. The problem is that the function is dependent on three parameters two of which are indexes of lists stored in the database, a change to any of these lists invalidates the function's cached results. What I need to implement is a cache where I can invalidate all cache items that have a dependency on a certain list index. At the moment, I have a database table which looks like this MembershipListID, AccessListID, OperationID, result, timestamp Everytime this function is called, I check to see if there is a result in the cache table, if the is I use it otherwise I do the work and an entry to the cache table. If the value of one of the lists changes I issue a delete for all records that use that list ID. Now I would like to move this to the ASP.NET cache for a bit more speed, and ease of management but am not sure how to. My best idea at the moment is to create dummy cache entries for each of the list indexes and then create a cache dependency on these keys for each result that goes into the cache, something like this. MembershipListID = 4 AccessListID = 8 OperationID = 3 Result = true So I would add the following place holders for creating cache dependencies MLID#4 ALID#8 I would then add another cache item with the key FR#4#8#3 with the value true and cache dependencies on MLID#4 and ALID#8 When one of the lists changes, I would remove the place holder key from the cache, for example MLID#4 and that would remove all the function results dependant on it. Is this the best way to solve something like this? Also while I have your attention, what is the accepted way to namespace your cache entries? I don't want my cache entries to get confused with another assemleblies data, so what do I do? Pre/post fix the key with the assembly name or public key? Thanks Stephen |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |