Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Кэшировать обращение к провайдерам в контейнере #16

Closed
smpl opened this issue Jun 9, 2019 · 0 comments · Fixed by #23
Closed
Labels
bug Something isn't working

Comments

@smpl
Copy link
Collaborator

smpl commented Jun 9, 2019

При загрузке зависимости каждый раз происходит поиск провайдера и загрузка через него, можно сохранять результат и возвращать уже готовый результат, это позволит не делать загрузку каждый раз и все возвращать инстанс одного и тоже объекта.

Пример

$providers[] = new KeyValue(['a' => new Service(function () {
   return new stdClass;
})])
$container = new Container(...$providers);
$a1 = $container->get('a');
$a2 = $container->get('a');

$this->assertSame($a1, $a2); // на текущий момент это утверждение не выполняется.
@smpl smpl added the bug Something isn't working label Jun 9, 2019
smpl added a commit that referenced this issue Jun 13, 2019
@smpl smpl closed this as completed in #23 Jun 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant