Prefetch from a cache

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 27-Jun-2012 20:14:59   

When I'm loading items from a shopping cart, lots of stuff gets prefetched around those items but the prefetched stuff rarely changes - its static stuff like products and payment methods. Is there some way of prefetching this stuff from an in memory cache instead of going to the database for all these items? I could do it manually but then I would have to write the code to build up the object graph instead of having LLBLGen do it.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 27-Jun-2012 20:34:56   

You can pre-load them and cache them in memory, instead of prefetching them each time.

Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 27-Jun-2012 22:03:26   

OK but do I need to look them up in the cache and build up the object graph manually?

So, for example, an order detail references a product. If I use a prefetch when fetching the order detail then the order detail instance will already be referencing the product. But if I store the product in memory then I will I need to assign it to the order detail's product property?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 28-Jun-2012 11:41:50   

Add all entities to a context, and use the context with the fetch, so you won't get duplicate instances.

Frans Bouma | Lead developer LLBLGen Pro
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 06-Jul-2012 03:42:50   

Sounds cool.