refactor: extract ResponseCache class for Web Page Caching#7644
refactor: extract ResponseCache class for Web Page Caching#7644kenjis merged 13 commits intocodeigniter4:4.4from
Conversation
|
The service returns the same object. Does it make sense to create an additional property? |
54ed30f to
715723d
Compare
911db4e to
dba3d1a
Compare
|
I'd like to suggest a change.
protected function cachePage(int $time)
{
Services::pagecache()->ttl($time);
}
|
|
Thank you for your comment. What about the namespace? Should be in |
I think the namespace should stay the same. |
0da0753 to
80465c6
Compare
system/CodeIgniter.php
Outdated
| 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.
public function 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.
|
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. ------ ------------------------------------------------------------------
d748ef1 to
cd5b817
Compare
|
Added changelog. |
Indeed, I am not sure if there is a use case. |
Co-authored-by: MGatner <mgatner@icloud.com>
Description
Checklist: