Recommend this page to a friend! |
Classes of Gjero Krsteski | Building an Identity Map in PHP | README.markdown | Download |
|
DownloadBuilding an Identity Map in PHPSample application used for training. This example code is no production code and should be used for training purposes only. This example code requires:
This example code implements:
Why identity mapping?By using Data-Mapper pattern without an identity map, you can easily run into problems because you may have more than one object that references the same domain entity. Data-Mapper without identity map
Data-Mapper with identity mapThe identity map solves this problem by acting as a registry for all loaded domain instances.
By using an identity map you can be confident that your domain entity is shared throughout your application for the duration of the request. Note that using an identity map is not the same as adding a cache layer to your mappers. Although caching is useful and encouraged, it can still produce duplicate objects for the same domain entity. Load the Data-Mappers with the Repository class
|