Open Source/plain-to-class/Advanced usage/Cache
Cache
The package supports a class caching mechanism to avoid the cost of reflection. This functionality is recommended to be used only if you have very voluminous classes, or there is a cyclic transformation of multiple entities. On ordinary lightweight DTOs, there will be only 5-10% gain, and this will be an unnecessary access to the file system.
You can enable caching by passing the config to the hydrator constructor:
(new Hydrator(new HydratorConfig(true))) ->create(PurchaseDto::class, $data);