English 中文(简体)
如何根据动态属性( 如评论中的类似次数) 排序时, 我如何执行光标页数?
原标题:How can I implement cursor pagination when sorting by dynamic attributes such as the number of likes on comments?

我想使用光标光标页从基于最喜欢的相似点的数据库中获取批注, 从最喜欢的类似点到最不喜欢它们, 并将其装入一个批注部分。 此功能旨在反映 Youtube S Top 批注 。 例如, 我加载一组批注, 并使用最后一个批注作为光标 。 可以说最后一个批注有 10 个喜欢 。 下一组要加载的批注应该小于或等于 10 个类似点 。 出现的问题是, 在我加载下一组批注之前, 下一组批注可能比光标更喜欢( 例如从 9 到 12 ) 的批注, 以及我已经加载和装入的批注少一些类似点( 例如从 14 到 7 ) 的批注。 所以当我加载下一组批注时, 那些已加载的批注可能会排除最近获得的类似和( 或) 已经加载的批注。

我尝试了Youtube S Top 批注的实验,看看它是否存在同样的问题,但我没有得到重复的或错过的评论。我知道ytube S Top 批注很可能使用复杂的算法来确定顶级评论,而不只是基于类似数字。是否有一种算法已经解决这个问题了?Youtube似乎已经解决了这个问题,但我不知道它们是如何解决这个问题的。我无法找到解决问题的有效办法。

问题回答

坦率地说,我对这种特征没有实践经验。

  • Accept refreshing the comment section if any updates occur: This approach may raise performance issues but improves the user experience.
  • Rank top comments by likes and time: When users access this section, include a field like max_updated_at in your request to the server to only get data about likes logged before this time. The query will include multiple conditions: updated_at <= max_updated_at (in the likes log table) and the number of likes should be less than or equal to the cursor s number of likes. You can achieve this using Redis Sorted Set, utilizing functions like ZADD and ZRANGEBYSCORE.




相关问题
what is wrong with this mysql code

$db_user="root"; $db_host="localhost"; $db_password="root"; $db_name = "fayer"; $conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die ("couldn t connect to server"); // perform query ...

Users asking for denormalized database

I am in the early stages of developing a database-driven system and the largest part of the system revolves around an inheritance type of relationship. There is a parent entity with about 10 columns ...

Easiest way to deal with sample data in Java web apps?

I m writing a Java web app in my free time to learn more about development. I m using the Stripes framework and eventually intend to use hibernate and MySQL For the moment, whilst creating the pages ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

How can I know if such value exists in database? (ADO.NET)

For example, I have a table, and there is a column named Tags . I want to know if value programming exists in this column. How can I do this in ADO.NET? I did this: OleDbCommand cmd = new ...

Convert date to string upon saving a doctrine record

I m trying to migrate one of my PHP projects to Doctrine. I ve never used it before so there are a few things I don t understand. In my current code, I have a class similar to this: class ...

热门标签