服务客户端库开发与负载均衡缓存策略
1. 服务客户端库开发
1.1 读取列表请求处理
读取列表已设置好所有用于获取读取列表的请求对象,并并行运行特定评分总数和条目的请求。通过调用 hydra.run 可一次性运行所有请求,最后将结果合并为一个条目对象集合。以下是 ReadingList 类中的 entries 方法:
def entries
return @entries if @includes_run
include_rating_total = @includes.include?(:rating_total)
if @includes.include?(:rating_total)
@entries.each_with_index do |entry, index|
entry.rating_total = @rating_totals[index]
end
end
@includes_run = true
@entries
end
此方法假定所有请求已运行,会遍历条目并为其分配关联的评分总数。这些类( ReadingList 、 Entry 和 Rating )仅创建请求对象并排队,运行请求的责任在这些类之外。
1.2 数据写入处理
数据写入与读取处理方式有所不同,通常数据写入无需并行执行,一
超级会员免费看
订阅专栏 解锁全文
552

被折叠的 条评论
为什么被折叠?



