Uh oh!
There was an error while loading. Please reload this page.
refactor: extract ResponseCache class for Web Page Caching - #7644
Conversation
iRedds
commented
Jun 30, 2023
The service returns the same object. Does it make sense to create an additional property? |
911db4e to
dba3d1aCompareiRedds
commented
Jun 30, 2023
I'd like to suggest a change.
protectedfunctioncachePage(int$time)
{
Services::pagecache()->ttl($time);
}
|
kenjis
commented
Jul 1, 2023
Thank you for your comment. What about the namespace? Should be in |
iRedds
commented
Jul 1, 2023
I think the namespace should stay the same. |
| if ($this->pageCache->getTtl() > 0) { | ||
| $this->pageCache->make($this->request, $this->response); | ||
| } |
There was a problem hiding this comment.
Thank you for considering my suggestion, but in this snippet, I meant a slightly different approach.
| if ($this->pageCache->getTtl() > 0) { | |
| $this->pageCache->make($this->request, $this->response); | |
| } | |
| $this->pageCache->make($this->request, $this->response); |
and then the decision on the need to cache the Response is made by the caching class.
publicfunction make($request, ResponseInterface$response): bool
{
if ($this->ttl === 0) {
return ; // bool (false or true)
}This is how I see the implementation, but I don't know if my approach is correct or not.
There was a problem hiding this comment.
If $ttl is 0, there is no need to cache it, so that seems a little better.
Done.
iRedds
commented
Jul 3, 2023
I have a little doubt, but it seems to me that there is no point in caching the response for the CLI. It seems to me that the current documentation is sufficient, since in fact nothing has changed for the end developer. |
Fixes the following errors: ------ ------------------------------------------------------------------ Line system/CodeIgniter.php ------ ------------------------------------------------------------------ 529 Parameter #1 $request of method CodeIgniter\Cache\PageCache::cachePage() expects CodeIgniter\HTTP\CLIRequest|CodeIgniter\HTTP\IncomingRequest, CodeIgniter\HTTP\Request|null given. 685 Parameter #1 $request of method CodeIgniter\Cache\PageCache::getCachedResponse() expects CodeIgniter\HTTP\CLIRequest|CodeIgniter\HTTP\IncomingRequest, CodeIgniter\HTTP\Request|null given. ------ ------------------------------------------------------------------
kenjis
commented
Jul 3, 2023
Added changelog. |
kenjis
commented
Jul 3, 2023
Indeed, I am not sure if there is a use case. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: MGatner <mgatner@icloud.com>
Description
Checklist: