0

我通过来自几个不同提供商的 WS 请求获得了一些结果,然后我收集并订购结果并将它们展示给用户。

结果的数量在 0 到 60-70 之间,平均为 10-20。我的问题是:如何处理分页?我试图找出最适合我的情况的解决方案,因为我已经找到了几种方法来做到这一点......而且我确信我错过了其他好的(可能更好)的解决方案......我认为的解决方案到现在:

1) 通过 Web 服务为每个页面(15 个结果)创建一个新的聚合搜索。这很愚蠢,但由于平均结果数为 10-20,因此不会经常使用分页。

2)将所有结果保存在数据库中作为临时缓存,然后一次显示15个结果

3)在单个页面中加载所有结果,但使用 Jquery 分页插件(客户端?)仅显示 15 个页面

4

2 回答 2

1

Are you really sure that someday the web services aren't going to start returning a lot more results? What if someday there is a bug in one of them where it accidentally returns 50,000 copies of the same result to you? In each of your solutions:

  1. A larger than expected number of results would cause you to spam the web services with repeated requests for the same results, as users page through them.

  2. A larger than expected number of results will end up temporarily taking up space in your database. Also, in a web app, how will you know when to clear the cache?

  3. A larger than expected number of results will end up as a huge page in the user's browser, possibly not rendering correctly until the whole thing is downloaded.

I really like option 3. The caching is done at the place where the data is wanted, there are no redundant hits to the web services, and paging will be super fast for the users.

If you're really certain no more than 60-70 results will ever be returned, and/or that your users will never want a really large number of results, you could combine option 3 with a cap on the number of results you will return.

Even in the worst case where the web services return erroneous/unexpected results, you could trim it to the first so many, send them down to the browser, and paginate them there with JavaScript.

于 2012-04-12T16:54:47.360 回答
1

这取决于 1 个结果有多大,但如果您最多有 60-70 个结果,我不希望分页,尤其是在不经常出现的情况下。更好的用户体验。

于 2012-04-11T23:42:45.743 回答