Skip to content

[Cache] Commit items implicitly only when deferred keys are requested #43302

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

Merged
merged 1 commit into from
Oct 6, 2021

Conversation

sbelyshkin
Copy link
Contributor

@sbelyshkin sbelyshkin commented Oct 3, 2021

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets
License MIT
Doc PR

Because of implicit commits before getting any item, deferred saves are useless.

for($r=0; $r<10; ++$r) {
    $item = $adapter->getItem('Key'.$r); // implicit commit
    $item->set('Value'.$r);
    $adapter->saveDeferred($item);
}
$adapter->commit(); // nothing to commit :-//

Let's commit deferred changes only when requested item was deferred previously.

@simonberger
Copy link
Contributor

Very nice find ! This is also an issue already in 4.4.

@sbelyshkin
Copy link
Contributor Author

It may be rebased or cherry-picked to 4.4.

@sbelyshkin sbelyshkin changed the base branch from 5.3 to 4.4 October 5, 2021 14:36
@nicolas-grekas nicolas-grekas modified the milestones: 5.3, 4.4 Oct 6, 2021
@nicolas-grekas
Copy link
Member

Thank you @sbelyshkin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants