Full cache

Posts   
 
    
Fabrice
User
Posts: 180
Joined: 25-May-2004
# Posted on: 19-May-2006 10:18:03   

Hi

I would like to put some type of entities in a full cache, I mean that all db entities are fetched and put in a cache (Currently I use a Context as cache, but I maybe will have to change that because I think I'll only cache the EntityFields of each Entity). The main goal of such type of cache is to greatly reduce db call because the cached object are very often accessed.

So I would like to know If it's possible to introduce this in the generated code ? I'm using the adapter scenario.

For the FetchEntity/FetchEntityCollection it's not a problem, I only have to override the methods in my derived DataAccessAdapter to look at the cache first.

The problem come from the fetch via prefetch path: I've try to override the FetchPrefetchPath method, but even if I manually fill the RetrievalCollection (of an IPrefetchPathElement2), the base method will fetch the data again.

Do you think there is a way to do that ? Thank you for your help !

sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 20-May-2006 18:22:07   

Hello What DB are you using. Most of DB's can be configured to cache most used queries and data. This is probably the easiest option if it is poosible.

You might want to look at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/caching1.asp?frame=true.

This is the cache application block. By default, it is designed to use Data Access Application Block, however you hasve the source code and also it accomodates extentions that could allow you to use it with LLBLGen.

Hope this helps.

Fabrice
User
Posts: 180
Joined: 25-May-2004
# Posted on: 23-May-2006 12:08:53   

Thanks for your help I'm using MSSQL but the problem is not related to the database, or to the cache mecanism.

I only want to know if there is a way to intercept the fetch that llblgen want to do to retrieve from another datasource than the db (to retrieve from the cache system)

I know I can override the FetchEntity(), FetchEntityCollection(), FetchEntityWithUniqueConstraint(). This will work for direct fetch of an object put in cache. But it' ll not work if the same object is fetched via prefetch path.

Concrete example : I want to put object A in a full cache. So I want to intercept all fetch for object A done by llblgen, I retrieve the object via the cache instead of db. If I override FetchEntity*, I can test if it's fetching object A But if Ifetch Object B with prefetch path to A, it's not work : A will be fetched from the db, not from the cache.

I hope It's clear because I've quite hard to explain it in English..

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39615
Joined: 17-Aug-2003
# Posted on: 24-May-2006 15:45:11   

Fabrice wrote:

Thanks for your help I'm using MSSQL but the problem is not related to the database, or to the cache mecanism.

I only want to know if there is a way to intercept the fetch that llblgen want to do to retrieve from another datasource than the db (to retrieve from the cache system)

I know I can override the FetchEntity(), FetchEntityCollection(), FetchEntityWithUniqueConstraint(). This will work for direct fetch of an object put in cache. But it' ll not work if the same object is fetched via prefetch path.

Yes it will, as prefetch path fetches will use FetchEntityCollection to do the work simple_smile

Frans Bouma | Lead developer LLBLGen Pro