Help on creating a SqlCacheDependancy

Posts   
 
    
Posts: 12
Joined: 14-May-2006
# Posted on: 17-Oct-2006 14:32:12   

Hi

I'm using the adapter model and i'm trying to setup a SqlCacheDependancy. I have found by searching the forum that I need to add the Code to the OnFetchEntity Event, but am unsure how I can go about this. Basically i don't know what I can cache and how to return it without making a call to the DB.

Also the, SqlDataSource has caching built in, are there any plans to add it to the llblgenDatasources?

Thanks

Richard

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 17-Oct-2006 15:56:08   

Hi,

looking into the doc, you'll find that you can set a dependency based on a tables name rather than a command, so digging into the generated code is not an obligation.

Now, as Frans stated (http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=5710 for reference), you can access the command object to finer define your dependency.

If you do so, you'll need to think about your dependency convention naming, since you may have various commands for a single table to deal with. Also, if you deal with many parameters such as paging I'm not sure about the overhead for the many dependencies. Probably better attach directly to the table in that case (check for the doc).

Now about how to handle that:

Create a caching controller abstracting the functionality, and in your business controller, update the methods calling the queries so that they get the corresponding keys (an enum + parameters might help serving the keys with more ease), check if the data is in cache, if it's there get it. If not run the query, put the result in cache attached to the dependency (you also need the depency's key right), and return the result.

My experience is that entities and collection get cached pretty well. Now be aware that the cache will perform shallow copy, so if you edit an entity, it will get changed right into the cache. You may also experience concurrent access problems . If you want to avoid that, take care of deep copying in your caching controller. That of course removes part of the perfs benefit but it's still ok.

Hope that helps