abdera-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ugo Cei <...@apache.org>
Subject Re: RFC-5005 best practices
Date Fri, 14 Dec 2007 20:14:09 GMT

On Dec 14, 2007, at 7:57 PM, James M Snell wrote:

> I've implemented paging a number of times.  The easiest approach has
> always been to use page and pagesize.  Doing so, however, has it's
> disadvantages.  For one, the pages are unstable -- that is, as new
> entries are added to the collection, the entries slide through the  
> pages
> making it difficult for a client to completely and consistently  
> sync up
> the changes.  An alternative approach would be to based paging on date
> ranges, each each page could represent all entries modified within a
> given period of time.  Such pages will generally be much less volatile
> over time.

What I did in a similar situation was using the first/last entry id  
instead. When you generate the first page, you take the id of the  
last entry and construct the 'next' link by append "before=<id-of- 
last-entry>". When generating the next page, the server has to look  
up all entries whose date is less than the date of the entry whose id  
has been passed as a parameter.

Similarly, you generate a 'previous' link by appending "after=<id-of- 

You can also avoid doing date comparisons if you can generate ids  
that are lexicographically order according to their age.

You can even use a range of ids to have more stable collections, as  
James suggests.


Ugo Cei
Sourcesense - making sense of Open Source: http://www.sourcesense.com

View raw message