百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

ar_lazy_preload

> 后端框架
开源

为 ActiveRecord 模型设置懒加载关联

740 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

为 ActiveRecord 模型设置懒加载关联

ArLazyPreload() (https://cultofmartians.com/tasks/activerecord-lazy-preload.html) (https://rubygems.org/gems/ar_lazy_preload) (https://github.com/DmitryTsepelev/ar_lazy_preload/actions/workflows/rspec.yml) (https://codeclimate.com/github/DmitryTsepelev/ar_lazy_preload/maintainability) (https://coveralls.io/github/DmitryTsepelev/ar_lazy_preload?branch=master)

ArLazyPreload 是一个 gem,它为您的 Rails 应用程序带来关联延迟加载功能。有许多内置方法可以解决 N+1 问题,但有时要预加载的关联列表并不明显,这就是您可以使用此 gem 的时候。

  • 简单。您需要更改的唯一事项是使用 #lazy_preload 而不是 #includes、#eager_load 或 #preload
  • 快速。请查看 性能基准测试 和 内存基准测试
  • 完美适合 GraphQL。在顶级解析器中定义要加载的关联列表,并让 gem 完成其工作
  • 自动预加载支持。如果您不想指定关联列表 - 将 ArLazyPreload.config.auto_preload 设置为 true

在生产环境中使用的项目包括:

如果您的 Rails 应用程序的性能问题超出了 N+1 查询,该怎么办?我可以提供咨询服务 - 联系我。

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rubyactiverecordeager-loadingrailsruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类后端框架
定价开源

> 相关工具

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架