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

Fix: race condition in caching layer #218

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Repository/DefaultUnleashRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,10 @@ private function getCachedFeatures(): ?array
{
$cache = $this->configuration->getCache();

if (!$cache->has(CacheKey::FEATURES)) {
$result = $cache->get(CacheKey::FEATURES);
if ($result === null) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this $results from cache could have empty arrays like []?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the previous iteration yeah, in this, that shouldn't happen unless something puts an empty array in there. Assuming no bugs are present in the code, that should only ever happen if the SDK is using a token that's connected to a project that has no features

return null;
}

$result = $cache->get(CacheKey::FEATURES, []);
assert(is_array($result));

return $result;
Expand Down
Loading