什么是Lazy Loading? [英] What is Lazy Loading?

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

问题描述

什么是Lazy Loading?



[阅读几个答案后编辑]
为什么人们经常使用这个词?



假设您只需使用ASP / ADO记录集,并将其与数据或ADO.NET数据源一起加载到gridview。


解决方案

我想我应该问为什么人们使用Lazy Loading这个词呢?它被称为懒惰加载,因为像一个懒惰的人,你正在推迟做一些你不想要的东西。相反的是Eager Loading,您可以在需要之前长时间加载东西。



如果您好奇为什么人们可能会使用延迟加载,请考虑采用一个LOOOOONG时间开始。这个应用程序可能正在做很多热切的加载...从磁盘加载东西,并且在需要之前进行计算和不久之后。



将此与延迟加载进行比较,应用程序的启动速度会更快,但是当您第一次需要做一些需要长时间运行的操作时,首次加载时可能会略有暂停。因此,使用懒惰加载,您将在运行应用程序的过程中摊销加载时间...并且您可能实际上可以从加载用户可能永远不会使用的内容中保存。


What is Lazy Loading?

[Edit after reading a few answers] Why do people use this term so often?

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?

解决方案

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.

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

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