Last active
August 13, 2022 18:23
-
-
Save mikemix/957f069044b06a36d11ea3c25f82f842 to your computer and use it in GitHub Desktop.
Revisions
-
mikemix revised this gist
Aug 13, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,13 +3,13 @@ /** @var LRUCacheInterface<User> $cache */ $cache = new LRUCache(50); foreach ($taskRepository->findAll() as $task) { // get the user from cache // phpStorm will correctly resolve the $user as the User class $user = $cache->get($task->getUserId()); if (null === $user) { $user = $userRepository->findById($task->getUserId()); $cache->add($user->getId(), $user); } -
mikemix revised this gist
Aug 13, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ foreach ($tasks->findAll() as $task) { // get the user from cache // phpStorm will correctly resolve the $user as the User class $user = $cache->get($task->getUserId()); if (null === $user) { $user = $users->findById($task->getUserId()); -
mikemix renamed this gist
Aug 13, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
mikemix created this gist
Aug 13, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ <?php /** @var LRUCacheInterface<User> $cache */ $cache = new LRUCache(50); foreach ($tasks->findAll() as $task) { // get the user from cache // phpStorm will correctly resolve the $user as the User class $user = $cache->get($task->getUserId()) ?? if (null === $user) { $user = $users->findById($task->getUserId()); $cache->add($user->getId(), $user); } $task->execute($user); }