..net version prior to 2.0 do not support cache dependencies at the database
level so you can either use your approache which seems sound to me, or you
can set a global flag to dirty everytime the lists changes. Test this flag
before retrieving cached results. if it is dirty, grab from the database and
update the flag to clean. Just depends on which way you want to go
architecture wise.
[quoted text, click to view] > 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
them so i'm not in a position to dispense advice.
--
Regards,
Alvin Bruney
[ASP.NET MVP
http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here...
http://tinyurl.com/27cok [quoted text, click to view] "Stephen Woolhead" <stephen@perfectphase.com> wrote in message
news:%23JFykyJuEHA.3200@TK2MSFTNGP14.phx.gbl...
> 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
>
>