PHP 中的原生惰性对象.pdf

编号:651736 PDF 32页 363.61KB 下载积分:VIP专享
下载报告请您先登录!

PHP 中的原生惰性对象.pdf

1、Revisiting lazy objects in PHP and Symfony nicolasgrekasLazy LoadingDont do anything unless really neededLazy LoadingCan save time and memoryPerfect for short-lived requestsAllows creating circular object graphs(Provides resetting for free)The 4 kinds of Lazy Loading Lazy Initialization Value holder

2、s Virtual proxies Ghost objectsLazy InitializationCheck properties for a marker value(usually null)and load them on demandclass LazyInitializedClass public function getData()return$this-data?=$this-doGetData();Lazy InitializationThe implementation is laziness-awareValue HoldersAn object with a publi

3、c getValue()methodclass LocatorHolder public function _construct(#AutowireLocator(workflow,name)private ContainerInterface$workflows)public function getWorkflow(string$name)return$this-workflows-get($name);class IterableHolder public function _construct(#AutowireIterator(workflow)private iterable$wo

4、rkflows)public function getWorkflows():Generator foreach($this-workflows as$workflow)yield$workflow;Value HoldersThe consumers are laziness-awareVirtual ProxiesAn object with the same interface as the real objectThe real object is created just-in-timeclass EntityManager implements EntityManagerInter

5、face/.public function find(string$class,$id)/.class VirtualChildEntityManager extends EntityManager private parent$em;private bool$isInitialized=false;public function _construct(private Closure$initializer)public function find(string$class,$id)if(!$this-isInitialized)($this-initializer)($this);retur

6、n$this-em-find($class,$id);class VirtualProxyEntityManager implements EntityManagerInterface private EntityManagerInterface$em;private bool$isInitialized=false;public function _construct(private Closure$initializer)public function find(string$class,$id)if(!$this-isInitialized)($this-initializer)($th

友情提示

1、下载报告失败解决办法
2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
4、本站报告下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。

本文(PHP 中的原生惰性对象.pdf)为本站 (芦苇) 主动上传,三个皮匠报告文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三个皮匠报告文库(点击联系客服),我们立即给予删除!

温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。
客服
商务合作
小程序
服务号
折叠