-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Cache] Add nonce based cache invalidation to ApcuAdapter #18716
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
Conversation
854459b
to
3bc0c33
Compare
} | ||
} | ||
foreach ($values as $id => $v) { | ||
$values[$id] = unserialize(substr($v, $this->nonceLen)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not moving this to the loop above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question: because unserialization involves userland code, which means can be slow. But IMHO we need to invalidate fast.
Having the nonce as a container parameter makes the APCu cache barely unusable in the |
Except that our system caches (serializer & validation for now) are not enabled in debug mode. |
I simplified the implementation to the very minimum so that no overhead is added anymore to each apcu_fetch/store. I also replaced the container parameter by an inline value for the nonce. It has the drawback that @xabbuh outlined: the cache in dev is going to be cleared more often than strictly required. Yet I think this does not matter compared to the main benefit (we even already disable most caches in dev): As you know, there is currently no way to invalidate an FPM/Apache apcu cache from the CLI, other than restarting FPM/Apache on deployment. Even if it's a best practice, not everyone is able to do it. |
👍 |
ping @symfony/deciders votes pendind for 3.1-beta which should/may be released tomorrow |
Thank you @nicolas-grekas. |
…ter (nicolas-grekas) This PR was merged into the 3.1-dev branch. Discussion ---------- [Cache] Add nonce based cache invalidation to ApcuAdapter | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - APCu cache invalidation is tedious because it can't be done from the cli. This PR adds and wires a nonce based cache invalidation strategy to work around this limitation. Commits ------- a7899fe [Cache] Add nonce based cache invalidation to ApcuAdapter
APCu cache invalidation is tedious because it can't be done from the cli.
This PR adds and wires a nonce based cache invalidation strategy to work around this limitation.