Profiles List lazy load

Topics: ASP.NET 2.0, Business Logic Layer
Feb 22, 2011 at 3:38 PM

Hello everybody,

I'm customizing the blogengine, in order to use an existing SqlServer database as a Membership, Roles and Profiles data layer, plus something more. The result will be some kind of "private" blog, with no anonymous users allowed, and only users belonging to a specific role allowed to comment posts.

This, thanks to the great flexibility of the code, has been no problem, BUT... I am making some tests and realising that i *could* have an issue on the FillProfiles method. I have a HUGE Profiles db (almost 32K!)... so I'd like to hear from you what's better.

I see the list of member profiles is static, thread-safe and loaded once, but... what do you think if I added some stronger lazy-loading logic in it?

What strategy would you use in this case?

thank you!

a.

Coordinator
Feb 23, 2011 at 9:32 AM

I suppose you first might want to test to see how it performs.  Probably slowly, but at least you'll get an idea of what it's like first.

If it's slow to load all that data and/or if the memory usage is very high after the data is loaded, I'm thinking you'll want to remove the "Profiles" property in AuthorProfile -- the property that calls BlogService.FillPosts().  You would then probably modify GetProfile() to load the requested profile directly from the DB.  You could add some caching in GetProfile() to keep profiles cached in memory for a while ... not all of them, but just the ones that specifically are requested.  When adding them to cache, you could have the cache expire after 5 minutes, as an example.