-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
refactor: extract ResponseCache class for Web Page Caching #7644
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
Description
Checklist: