CustomerRegistry
Magento\Customer\Model\CustomerRegistry
What it does
CustomerRegistry acts as an in-memory cache for Customer models in Magento 2, storing loaded customers by ID and email to avoid repeated database queries within a single request.
Developers use this registry to retrieve customer instances efficiently and ensure they're working with the same object instance throughout the request lifecycle.
It automatically clears cached data after each request to prevent memory leaks in long-running processes.
Public Methods
- retrieve()
- retrieveByEmail()
- retrieveSecureData()
- remove()
- removeByEmail()
- push()
- _resetState()