View Single Post
  #71 (permalink)  
Old September 18th, 2007, 06:00 AM
jimibt jimibt is offline
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Quote:
quote:Originally posted by Maxxim
 
Quote:
quote:looking fwd to seeing a more 'clever' and efficient way to do this, as it'd be a nice way to work with sub-sets of data. can you think of a good way to extend this in such a way??


Hello jimi!
I think your code is well!

If you have 6 categories, you call "BLL.Forums.Forum.GetForums();" six times, but only do a connection to db the first time because the last five times you gonna catch this list(allforums) from cache!!

I think it's enough!
At the mean time I need to (read the book)/(view the code) about the rest part of the forums stuff...
I need to see how the cache system works everytime a user see one post (because viewcount increment +1). But this is outside of "categories/Foruns" page!

By curiosity, how much time do you have for your "CacheDuration" ?
i set the cacheduration to the default of 600 seconds. also, i update the actual object when calcualting the postcount. so, rather than having the cache purged on the IncrementViewCount (in Post.cs), i update post.ViewCount++; in the ShowThread.aspx.cs code. this means that altho' the database is actually updated, the threadlist isn't requeried but the post object reflects each new 'view'.

[edit] just thinking out loud now. it might be a 'good' idea to have a mod function running over the object (post) ViewCount value and only update (database) every n-views, whilst still maintaning the value in the object itslef. this way the database access would be kept to abare minimum and if all went wrong (i.e. server crashed), then only n-number of views would be missed (i.e. if the mod value was 10, then only a maximum of 10 viewcount increments would be lost in any system crash). on a heavily trafficed site, this would ease the load enormously. in fact, i'd be tempted to set the mod value to anywhere between 15 and 25.
jimi

http://www.originaltalent.com