Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 23rd, 2007, 01:37 AM
Authorized User
 
Join Date: Jun 2006
Location: Lahore, , Pakistan.
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default Rating &ViewCount do not increment

Hi everyone.
Did anyone notice that the Rating and ViewCount do not increment in TheBeerHouse when you view it live. The same is the case when I view it locally. Whats wrong?

And can anyne tell me why Mr.Marco Bellinaso is not blogging? Its been a long long time I see him blogging? It seems he's busy. But I didn't see him blogging this year.

  #2 (permalink)  
Old May 25th, 2007, 07:21 AM
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hello,

excuse me for my english, i prefer french ;) ok.
it's normal that's rating and viewcount not increment, this is because the data you show is retrieved from cache :) if you disable cache from web.config it's will work fine but you lose performance.

cheers.

  #3 (permalink)  
Old May 25th, 2007, 12:32 PM
Authorized User
 
Join Date: Jun 2006
Location: Lahore, , Pakistan.
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanx for your reply.
When data is changed in database, the cache gets updated (the old cached data is purged out).
When a new comment/rating is added to some article and so the view count increases, it should get updated.
My point is why the system ins't showing the updated data?

  #4 (permalink)  
Old May 26th, 2007, 05:45 PM
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hello,

i'am agree with you. When data is changed in database, the cache gets updated (the old cached data is purged out) but only for InsertArticle, UpdateArticle and DeleteArticle methods and not for IncrementArticleViewCount and RateArticle why :

look at methods implementations, there no call to BizObject.PurgeCacheItems method.

 public static bool IncrementArticleViewCount(int id)
      {
         return SiteProvider.Articles.IncrementArticleViewCount(id );
      }

      /// <summary>
      /// Increments an article's view count
      /// </summary>
      public static bool RateArticle(int id, int rating)
      {
         return SiteProvider.Articles.RateArticle(id, rating);
      }

but for DeleteArticle for example :

 public static bool DeleteArticle(int id)
      {
         bool ret = SiteProvider.Articles.DeleteArticle(id);
         new RecordDeletedEvent("article", id, null).Raise();
         BizObject.PurgeCacheItems("articles_article");
         return ret;
      }

i hope that can help you .

cheers



  #5 (permalink)  
Old May 27th, 2007, 02:07 PM
Authorized User
 
Join Date: Jun 2006
Location: Lahore, , Pakistan.
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanx.
Okay.. so don't you think we should also discard the cache for rating and view count whenever these two gets updated?
Otherwise it looks strange to the visitors that their rating is not getting added imediately.

  #6 (permalink)  
Old May 27th, 2007, 06:24 PM
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

we purge only concerned article :). not tested but i think this will work.

       /// <summary>
      /// Increments an article's view count
      /// </summary>
      public static bool RateArticle(int id, int rating)
      {
            BizObject.PurgeCacheItems("Articles_Article_" + id.ToString());
         return SiteProvider.Articles.RateArticle(id, rating);

      }

cheers.

  #7 (permalink)  
Old May 28th, 2007, 03:08 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

as an aside - you probably don't want to purge the cache in the IncrementArticleViewCount. the reason being that you'd always visit the database for each subsequent article (i.e. every visit to the article would cause a refresh as the incrementviewcount method would be called!!). better in this instance to just let the cache refresh by default (i.e. after 600 seconds). likewise, for the RateArticle, you might want to google 'ReluctantCacheHelper'. this little helper class let's you determine wheter the cache should be refreshed every time something changes or indeed whether the data is cached on the 1st query etc.. this is useful as it means that indexing spiders don't force your whole database into cache as they crawl the site.

as i said, google 'ReluctantCacheHelper' for full details, it'll make more sense when you read it in the author's page.

the link is:

http://weblogs.asp.net/gavinjoyce/pa...e-Pattern.aspx

jimi

http://www.jamestollan.com
  #8 (permalink)  
Old May 28th, 2007, 05:29 AM
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hello,

thank you for your reply and link

  #9 (permalink)  
Old May 28th, 2007, 10:28 AM
Authorized User
 
Join Date: Jun 2006
Location: Lahore, , Pakistan.
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, both of you.
I guess things are now getting clear to me.

  #10 (permalink)  
Old May 29th, 2007, 03:48 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

tectrix,

for the viewcount stuff, you could try the following:

        public static bool IncrementArticleViewCount(int id)
        {
            //BizObject.PurgeCacheItems("articles_article_" + id.ToString());
            Article article = Article.GetArticleByID(id);
            if (article != null)
            {
                article.ViewCount++;
            }
            return SiteProvider.Articles.IncrementArticleViewCount(id );
        }

this would mean that you'd be incrementing the object, rather than purging the database each time, therefore, each visit to the article would show an updated viewcount number without the database having to be visited.

jimi

http://www.jamestollan.com
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running up the ViewCount Lee Dumond BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 6 August 20th, 2009 10:38 AM
Reset Article View Count and Rating retroviz BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 July 20th, 2008 10:43 AM
Increment By Range & Output Solver Result ibrahim ahmad Excel VBA 0 April 30th, 2008 10:16 PM
Javascript && keeps turnig into &amp;&amp; ayrton Pro VB.NET 2002/2003 3 June 27th, 2005 03:34 PM
Linux & KDE & C++ & QT & MYSQL & Kdevelop Munnnki Linux 0 January 2nd, 2005 05:41 PM



All times are GMT -4. The time now is 08:26 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.