-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
Breaking changes of Cache::put #13847
Comments
Yes, we have made breaking changes. Laravel does not follow semver. Each minor version is like a sever major version. |
If we broke something in L5.2, please send a PR with whatever fix you see most appropriate, and we can take it from there. We can then discuss the finalizations to L5.3, if more changes are needed there. |
So breaking change is OK, but the situation is not still OK for L5.3. Another bad thing is here: putMany() still does not support seconds. If opening issues for the next version is not allowed, then this should be closed, otherwise it needs to remain open. @GrahamCampbell |
public function put($key, $value, $minutes = null)
{
if (is_array($key) && filter_var($value, FILTER_VALIDATE_INT) !== false) {
return $this->putMany($key, $value);
}
... |
Not at all! Please do let us know if we mess up on any version 5.1 or greater.
Ah, ok, I see. Could you send a PR to L5.3 to fix this please? |
Related to #13831, #13810, #5860, and 37267d0
BC 1
Cache::put('foo', 'bar', 0)
andCache::put('foo', 'bar', '0')
andCache::getStore()->put('foo', 'bar', 0)
in Laravel <=5.2 means cache forever, except for:- DatabaseStore: caches for 0 second.
- RedisStore: cache for 1min or 1sec, depending on if #13810 is applied.
In Laravel 5.3,
Cache::put('foo', 'bar', 0)
andCache::put('foo', 'bar', '0')
means don't cache at all across all the stores andCache::getStore()->put('foo', 'bar', 0)
will behave as in Laravel <= 5.2.BC 2
Cache::put('foo', 'bar', 0.0001)
andCache::getStore()->put('foo', 'bar', 0.0001)
andCache::getStore()->put('foo', 'bar', '0')
in Laravel <= 5.2 mean cache forever, except- DatabaseStore and FileStore: caches for 0 second.
- RedisStore: cache for 1min or 1sec, depending on if #13810 is applied.
In Laravel 5.3,
Cache::put('foo', 'bar', 0.0001)
andCache::getStore('foo', 'bar', 0.0001)
andCache::getStore('foo', 'bar', '0')
means cache forever except:- for DatabaseStore: caches for 0 second.
- for Redis store: cache for 1min or 1sec, depending on if #13810 is applied.
- for FileStore: cache for 0 second.
In summary
It was a headache. And the headache is doubled by me :( There could be more breaking changes.
Lets think of a solution that helps us. Another breaking change is required!
Solution 1
Let
Cache::put('foo', 'bar', $x)
, andCache::getStore()->put('foo', 'bar', $x)
mean don't cache if and only if(int) ($x * 60) < 1
And
Cache::put('foo', 'bar', INF)
, andCache::getStore()->put('foo', 'bar', INF)
mean cache forever.Solution 2
Using integer $seconds instead of $minutes in all the APIs and let `Cache::put('foo', 'bar', 0) mean cache forever across different cache stores.
Solution 3
Revert my changes, but make different cache stores behave the same. Namely fix DatabasStore and RedisStore.
I will try solution 1.
The text was updated successfully, but these errors were encountered: