weeeBox / mobile-system-design

A simple framework for mobile system design interviews
Other
4.05k stars 427 forks source link

Questions about Pagination by Cursor #17

Open javierfloresfont opened 2 years ago

javierfloresfont commented 2 years ago

Hello,

Thanks for the article, it is very helpful.

I have some questions about Pagination by Cursor (I don't have experience using it).

Looking at the document, in the response from the API, we can see something like this:

"cursor": {
    "count": 20,
    "next_id": "p1235xzy",
    "prev_id": null
  }

And in the database, we are adding into "feed" database table the following properties (for each item):

cursor_next_id: String # points to the next cursor page
cursor_prev_id: String # points to the prev cursor page

My questions are:

arjunaud commented 2 years ago

@weeeBox Thanks for the nice article. Could you please let me know when do we use cursor_prev_id? As @javierfloresfont mentioned it is required only if we are using pagination when scrolling up? But since we have already those items cached in db should we make the pagination call using cursor_prev_id while scrolling up? And also had some doubts like how do we handle server item delete in cursor based pagination and when do invalidate the cached items in the database?