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

Breaking changes of Cache::put #13847

Closed
halaei opened this issue Jun 3, 2016 · 6 comments
Closed

Breaking changes of Cache::put #13847

halaei opened this issue Jun 3, 2016 · 6 comments

Comments

@halaei
Copy link
Contributor

halaei commented Jun 3, 2016

Related to #13831, #13810, #5860, and 37267d0

BC 1

Cache::put('foo', 'bar', 0) and Cache::put('foo', 'bar', '0') and Cache::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) and Cache::put('foo', 'bar', '0') means don't cache at all across all the stores and Cache::getStore()->put('foo', 'bar', 0) will behave as in Laravel <= 5.2.

BC 2

Cache::put('foo', 'bar', 0.0001) and Cache::getStore()->put('foo', 'bar', 0.0001) and Cache::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) and Cache::getStore('foo', 'bar', 0.0001) and Cache::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), and Cache::getStore()->put('foo', 'bar', $x) mean don't cache if and only if (int) ($x * 60) < 1
And Cache::put('foo', 'bar', INF), and Cache::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.

@halaei halaei changed the title Breaking changes of Cache::put('foo', 'bar', 0) and Cache::getStore()::put('foo', 'bar', 0) Breaking changes of Cache::put Jun 3, 2016
@GrahamCampbell
Copy link
Member

Yes, we have made breaking changes. Laravel does not follow semver. Each minor version is like a sever major version.

@GrahamCampbell
Copy link
Member

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.

@halaei
Copy link
Contributor Author

halaei commented Jun 3, 2016

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

@halaei
Copy link
Contributor Author

halaei commented Jun 3, 2016

    public function put($key, $value, $minutes = null)
    {
        if (is_array($key) && filter_var($value, FILTER_VALIDATE_INT) !== false) {
            return $this->putMany($key, $value);
        }
        ...

@GrahamCampbell
Copy link
Member

GrahamCampbell commented Jun 3, 2016

If opening issues for the next version is not allowed

Not at all! Please do let us know if we mess up on any version 5.1 or greater.

but the situation is not still OK for L5.3. Another bad thing is here: putMany() still does not support seconds.

Ah, ok, I see. Could you send a PR to L5.3 to fix this please?

@vlakoff
Copy link
Contributor

vlakoff commented Jan 13, 2018

Refs subsequent fixes: #13868 and #13869.

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

No branches or pull requests

3 participants