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

[5.3] Fix cache get minutes #13869

Merged
merged 1 commit into from
Jun 4, 2016
Merged

Conversation

halaei
Copy link
Contributor

@halaei halaei commented Jun 3, 2016

Cache::put() will never Call Store::put() when $minutes is too close to zero, which can mean caching forever, or for 1 second, or for zero second. If someone needs to cache forever, he/she should call Cache::forever(). If someone do Cache::getStore()->put(), the behavior varies across different stores. Maybe no one does that!

@GrahamCampbell
Copy link
Member

GrahamCampbell commented Jun 3, 2016

This isn't right? We want the minutes to be a float?

@@ -490,7 +490,7 @@ protected function getMinutes($duration)
$duration = Carbon::now()->diffInSeconds(Carbon::instance($duration), false) / 60;
}

return $duration > 0 ? $duration : null;
return (int) ($duration * 60) > 0 ? $duration : null;
}
Copy link
Contributor Author

@halaei halaei Jun 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It means if duration is less than 1 second, don't bother store, because we don't know what it is going to do!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, wait, I missread this. I read it as being:

(int) (($duration * 60) > 0 ? $duration : null)

But, of course, PHP's precedence doesn't work like that.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@halaei it means if duration is less than 1 MINUTE...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means you cannot cache things for less than one minute. See for example https://laracasts.com/discuss/channels/general-discussion/caching-less-than-1-minute?page=1

@halaei
Copy link
Contributor Author

halaei commented Jun 3, 2016

Travis is confused too.

@GrahamCampbell
Copy link
Member

Looks correct. 👍

@taylorotwell taylorotwell merged commit 2813687 into laravel:5.3 Jun 4, 2016
@ObliviousHarmony
Copy link

@GrahamCampbell

Just wanted to let you know that this was a breaking change for one of the libraries in my application.

@GrahamCampbell
Copy link
Member

Laravel does not follow semver. We have plenty of breaking changes in 5.3. This was intentional. We specifically put itto 5.3 rather than 5.2 because it was breaking.

@ObliviousHarmony
Copy link

Not a problem, just wanted to let you know in case you did!

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

Successfully merging this pull request may close these issues.

5 participants