-
Notifications
You must be signed in to change notification settings - Fork 18
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
The cache should validate that found items were actually created by it / meant for it #22
Comments
Another possible solution would be to treat that cache data as invalid/empty and overwrite it if needed. |
That'd be fine with me too, but may lead to two separate systems continuously overwriting the value |
Yeah. That is why one would need the PrefixedCache php-cache/cache#96 =) If we do not overwrite we risk that random garbage data from an other service blocks this cache key forever. That would mean that we never can cache. |
i would vote that we implement overwriting then. if you use a different cache instance per service you can already use different paths, and ifnot the PR @Nyholm did will further improve the situation. still, data on a disk could be corrupted for whatever reason (incomplete write, actual disk failure, other types of "this should never happens" errors) so stopping to cache sounds wrong. |
I think overwriting should be the way to go. @naderman cache libraries and cache systems usually support namespacing, so avoiding collision is the responsibility of the user to configure it IMO. |
IMO it should just fail hard and throw an exception. It's clearly a configuration mistake that needs to be fixed. |
its an error, yes, but in production mode you rather want things to survive than a hard exception. it can log an error, or if it can know we are in some sort of dev mode, it can throw an exception. |
In that case throw a warning each time and ignore the cache. It ought to be fixed. |
yeah agree, trigger a warning level error sounds like the right thing to do. ignoring the cache in that case could lead to cache stop working at some point down the road if it either got corrupted by a random filesystem accident, or a hard crash mid-writing to the cache, or because we changed the format (maybe by accident, or in a new major version). thus i think overwriting should be ok in that case. |
That's a good point, indeed. 👍 |
Actual Behavior
The cache uses any item matching the key and may error if the content does not match what it expects.
Expected Behavior / Possible Solution
The cache should treat an item that was potentially created by another service with a colliding key as a reason to skip caching the resource with this key.
The text was updated successfully, but these errors were encountered: