RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1155 | Replies: 4
Reply
Join Date: Apr 2005
Location: Kerala
Posts: 172
Reputation: hbmarar is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
hbmarar's Avatar
hbmarar hbmarar is offline Offline
Junior Poster

commenting system and pagination issue : commenting with filw system storage

  #1  
Mar 15th, 2007
Hi,

I have created a commenting system which could be used for commenting articles posted. The trouble is that after doing all the development I am stuck with pagination.The architecture to store comments is to hold in filesystem in the following way.

Article
{Folder 1}
Reply 1
Reply to 1 as 1.n
reply to 1.n as 1.n.n
......
{Folder 2}
Reply 2
{Folder 3}
Reply 3

In this scenario, to boost performance i thought of getting a pagination developed . i have developed pagination system as well. The problem here is , if Folder 1 has total 16 comments and folder 2 has 12 comments, per page limit say 10. how would paginatino realize that page 2 has to list 6 comments from folder 1 and 4 from folder 2.

Thanks for the consideration and i request some hints and pointers that i could use. it would be gr8 if anyone here could share some codes / logics

Harish
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2005
Posts: 716
Reputation: digital-ether has a spectacular aura about digital-ether has a spectacular aura about 
Rep Power: 6
Solved Threads: 44
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Master Poster

Re: commenting system and pagination issue : commenting with filw system storage

  #2  
Mar 17th, 2007
I think you'll have to cache the number of files in each folder. Otherwise you'll have to recurse through the folders each time counting the number of files each time you call the pagination script.

How are you doing it at the moment?
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote  
Join Date: Apr 2005
Location: Kerala
Posts: 172
Reputation: hbmarar is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
hbmarar's Avatar
hbmarar hbmarar is offline Offline
Junior Poster

Re: commenting system and pagination issue : commenting with filw system storage

  #3  
Mar 17th, 2007
Thanks ether for post and query.

Actually I am be caching it. We have a SQUID architecture and above all i am using memcache for caching. So i think it is fine.

The concern of 1 system files list call and 2 file read system calls for each comment display in a list of comments is well addressed with caching.

The concern is that on click of say '2' in pagination bar how would i make out that i have to start from file X.X.N in folder A to X.Y in folder B.

This is where I am stuck and worried because after developing the whole API this is where i am left like lost planet.

Yesterday i thought in terms of Btrees or something that sort so that i go through all and then reduce the system calls for reading to painated refered pages clicked. something like this ... it seems like i would go mad now...

some pointers and help appreciated.
Reply With Quote  
Join Date: Sep 2005
Posts: 716
Reputation: digital-ether has a spectacular aura about digital-ether has a spectacular aura about 
Rep Power: 6
Solved Threads: 44
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Master Poster

Help Re: commenting system and pagination issue : commenting with filw system storage

  #4  
Mar 19th, 2007
Originally Posted by hbmarar View Post
Thanks ether for post and query.

Actually I am be caching it. We have a SQUID architecture and above all i am using memcache for caching. So i think it is fine.

The concern of 1 system files list call and 2 file read system calls for each comment display in a list of comments is well addressed with caching.

The concern is that on click of say '2' in pagination bar how would i make out that i have to start from file X.X.N in folder A to X.Y in folder B.

This is where I am stuck and worried because after developing the whole API this is where i am left like lost planet.

Yesterday i thought in terms of Btrees or something that sort so that i go through all and then reduce the system calls for reading to painated refered pages clicked. something like this ... it seems like i would go mad now...

some pointers and help appreciated.


If you cache the number or files in each folder like: (using your example)

Article
{Folder 1}
Reply 1
Reply to 1 as 1.n
reply to 1.n as 1.n.n
......
{Folder 2}
Reply 2
{Folder 3}
Reply 3

Say you cache an array.
[PHP]$article1_counts = Array('folder1'=>3, 'folder2'=>1, 'folder3'=>3);[/PHP]

say your limit is 5 (to make the example work).

Then 1 would be folder1 and folder2 and 1 file from folder 3.
Then 2 would be 2 files from folder three and the rest from article 2.

That would do some of the work, then you'll have to read the folders from the disk to get just which files you want to start and end with - but it would narrow you to reading a maximum of 2 overlapping folders.

In memcached you could create an Array which indexes each artilce. Like:

[PHP]$article_counts = array($article1_counts, $article2_counts, ...);[/PHP]

But add and remove each index depending on how many times its hit to keep it small. eg: if there isn't any hits on article 2 for an hour it definitely should not have lived in memcached for an hour since thats more than the cache lifetime on SQUID I bet...

I've never worked with memcached or Squid though so I'm just guessing here..

I'm choosing just the "count's" here cause it seems the easiest to update. Say a new comment is made, just have to update the count in the folder the comment file will be in...

Am I even close to what you're getting at?
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote  
Join Date: Apr 2005
Location: Kerala
Posts: 172
Reputation: hbmarar is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
hbmarar's Avatar
hbmarar hbmarar is offline Offline
Junior Poster

Re: commenting system and pagination issue : commenting with filw system storage

  #5  
Mar 19th, 2007
Hi ether,

Your reply seems a nice pointer for me to think and work out. Aaah a way out i feel so. Thanks. I would give a try after some thoughts and post an update.

Thanks once again for the patience.

Harish
Originally Posted by digital-ether View Post
If you cache the number or files in each folder like: (using your example)

Article
{Folder 1}
Reply 1
Reply to 1 as 1.n
reply to 1.n as 1.n.n
......
{Folder 2}
Reply 2
{Folder 3}
Reply 3

Say you cache an array.
[PHP]$article1_counts = Array('folder1'=>3, 'folder2'=>1, 'folder3'=>3);[/PHP]

say your limit is 5 (to make the example work).

Then 1 would be folder1 and folder2 and 1 file from folder 3.
Then 2 would be 2 files from folder three and the rest from article 2.

That would do some of the work, then you'll have to read the folders from the disk to get just which files you want to start and end with - but it would narrow you to reading a maximum of 2 overlapping folders.

In memcached you could create an Array which indexes each artilce. Like:

[PHP]$article_counts = array($article1_counts, $article2_counts, ...);[/PHP]

But add and remove each index depending on how many times its hit to keep it small. eg: if there isn't any hits on article 2 for an hour it definitely should not have lived in memcached for an hour since thats more than the cache lifetime on SQUID I bet...

I've never worked with memcached or Squid though so I'm just guessing here..

I'm choosing just the "count's" here cause it seems the easiest to update. Say a new comment is made, just have to update the count in the folder the comment file will be in...

Am I even close to what you're getting at?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:15 pm.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC