什么是延迟加载? [英] What is Lazy Loading?

查看:23
本文介绍了什么是延迟加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是延迟加载?

[阅读几个答案后编辑]为什么人们如此频繁地使用这个词?

Why do people use this term so often?

假设您只使用 ASP/ADO 记录集并为它加载数据或用于 gridview 的 ADO.NET 数据源.

Say you just use a ASP/ADO recordset and load it with data or ADO.NET Datasource for a gridview.

我想我应该问为什么人们使用术语延迟加载,他们的其他"类型是什么?

I guess I should have asked why people use the term Lazy Loading, what "other" types are their?

推荐答案

它被称为延迟加载,因为,就像一个懒惰的人,你会推迟做你不想做的事情.相反的是 Eager Loading,您可以在需要之前立即加载.

It's called lazy loading because, like a lazy person, you are putting off doing something you don't want to. The opposite is Eager Loading, where you load something right away, long before you need it.

如果您想知道为什么人们可能会使用延迟加载,请考虑一个需要很长时间才能启动的应用程序.这个应用程序可能正在做很多急切加载...从磁盘加载东西,并在需要它之前进行计算和诸如此类的事情.

If you are curious why people might use lazy loading, consider an application that takes a LOOOOONG time to start. This application is probably doing a lot of eager loading... loading things from disk, and doing calculations and whatnot long before it is ever needed.

将此与延迟加载进行比较,应用程序会启动得更快,但是当您第一次需要执行一些需要长时间运行的加载时,第一次加载时可能会出现轻微的停顿.因此,通过延迟加载,您可以在整个应用程序运行过程中分摊加载时间……而且您实际上可以避免加载用户可能永远不会使用的内容.

Compare this to lazy loading, the application would start much faster, but then the first time you need to do something that requires some long running load, there may be a slight pause while it is loaded for the first time. Thus, with lazy loading, you are amortizing the load time throughout the course of running your application... and you may actually save from loading things that the user may never intend to use.

这篇关于什么是延迟加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆