Skip to content

Commit 8b0230a

Browse files
committed
refactor: rename getCachedResponse() to get()
1 parent d0b9868 commit 8b0230a

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

deptrac.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ parameters:
222222
- Cache
223223
skip_violations:
224224
# Individual class exemptions
225-
CodeIgniter\Cache\PageCache:
225+
CodeIgniter\Cache\ResponseCache:
226226
- CodeIgniter\HTTP\CLIRequest
227227
- CodeIgniter\HTTP\IncomingRequest
228228
- CodeIgniter\HTTP\ResponseInterface

system/Cache/ResponseCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function make($request, ResponseInterface $response, int $ttl): bool
9494
*
9595
* @param CLIRequest|IncomingRequest $request
9696
*/
97-
public function getCachedResponse($request, ResponseInterface $response): ?ResponseInterface
97+
public function get($request, ResponseInterface $response): ?ResponseInterface
9898
{
9999
if ($cachedResponse = $this->cache->get($this->generateCacheKey($request))) {
100100
$cachedResponse = unserialize($cachedResponse);

system/CodeIgniter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ protected function forceSecureAccess($duration = 31_536_000)
684684
*/
685685
public function displayCache(Cache $config)
686686
{
687-
if ($cachedResponse = $this->pageCache->getCachedResponse($this->request, $this->response)) {
687+
if ($cachedResponse = $this->pageCache->get($this->request, $this->response)) {
688688
$this->response = $cachedResponse;
689689

690690
$this->totalTime = $this->benchmark->getElapsedTime('total_execution');

tests/system/Cache/ResponseCacheTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ public function testCachePageIncomingRequest()
107107

108108
// Check cache with a request with the same URI path.
109109
$request = $this->createIncomingRequest('foo/bar');
110-
$cachedResponse = $pageCache->getCachedResponse($request, new Response($this->appConfig));
110+
$cachedResponse = $pageCache->get($request, new Response($this->appConfig));
111111

112112
$this->assertInstanceOf(ResponseInterface::class, $cachedResponse);
113113
$this->assertSame('The response body.', $cachedResponse->getBody());
114114
$this->assertSame('abcd1234', $cachedResponse->getHeaderLine('ETag'));
115115

116116
// Check cache with a request with the same URI path and different query string.
117117
$request = $this->createIncomingRequest('foo/bar', ['foo' => 'bar', 'bar' => 'baz']);
118-
$cachedResponse = $pageCache->getCachedResponse($request, new Response($this->appConfig));
118+
$cachedResponse = $pageCache->get($request, new Response($this->appConfig));
119119

120120
$this->assertInstanceOf(ResponseInterface::class, $cachedResponse);
121121
$this->assertSame('The response body.', $cachedResponse->getBody());
@@ -124,7 +124,7 @@ public function testCachePageIncomingRequest()
124124
// Check cache with another request with the different URI path.
125125
$request = $this->createIncomingRequest('another');
126126

127-
$cachedResponse = $pageCache->getCachedResponse($request, new Response($this->appConfig));
127+
$cachedResponse = $pageCache->get($request, new Response($this->appConfig));
128128

129129
$this->assertNull($cachedResponse);
130130
}
@@ -147,22 +147,22 @@ public function testCachePageIncomingRequestWithCacheQueryString()
147147

148148
// Check cache with a request with the same URI path and same query string.
149149
$this->createIncomingRequest('foo/bar', ['foo' => 'bar', 'bar' => 'baz']);
150-
$cachedResponse = $pageCache->getCachedResponse($request, new Response($this->appConfig));
150+
$cachedResponse = $pageCache->get($request, new Response($this->appConfig));
151151

152152
$this->assertInstanceOf(ResponseInterface::class, $cachedResponse);
153153
$this->assertSame('The response body.', $cachedResponse->getBody());
154154
$this->assertSame('abcd1234', $cachedResponse->getHeaderLine('ETag'));
155155

156156
// Check cache with a request with the same URI path and different query string.
157157
$request = $this->createIncomingRequest('foo/bar', ['xfoo' => 'bar', 'bar' => 'baz']);
158-
$cachedResponse = $pageCache->getCachedResponse($request, new Response($this->appConfig));
158+
$cachedResponse = $pageCache->get($request, new Response($this->appConfig));
159159

160160
$this->assertNull($cachedResponse);
161161

162162
// Check cache with another request with the different URI path.
163163
$request = $this->createIncomingRequest('another');
164164

165-
$cachedResponse = $pageCache->getCachedResponse($request, new Response($this->appConfig));
165+
$cachedResponse = $pageCache->get($request, new Response($this->appConfig));
166166

167167
$this->assertNull($cachedResponse);
168168
}
@@ -182,15 +182,15 @@ public function testCachePageCLIRequest()
182182

183183
// Check cache with a request with the same params.
184184
$request = $this->createCLIRequest(['foo', 'bar']);
185-
$cachedResponse = $pageCache->getCachedResponse($request, new Response($this->appConfig));
185+
$cachedResponse = $pageCache->get($request, new Response($this->appConfig));
186186

187187
$this->assertInstanceOf(ResponseInterface::class, $cachedResponse);
188188
$this->assertSame('The response body.', $cachedResponse->getBody());
189189

190190
// Check cache with another request with the different params.
191191
$request = $this->createCLIRequest(['baz']);
192192

193-
$cachedResponse = $pageCache->getCachedResponse($request, new Response($this->appConfig));
193+
$cachedResponse = $pageCache->get($request, new Response($this->appConfig));
194194

195195
$this->assertNull($cachedResponse);
196196
}
@@ -218,7 +218,7 @@ public function testUnserializeError()
218218
$cache->save($cacheKey, 'Invalid data');
219219

220220
// Check cache with a request with the same URI path.
221-
$pageCache->getCachedResponse($request, new Response($this->appConfig));
221+
$pageCache->get($request, new Response($this->appConfig));
222222
}
223223

224224
public function testInvalidCacheError()
@@ -244,6 +244,6 @@ public function testInvalidCacheError()
244244
$cache->save($cacheKey, serialize(['a' => '1']));
245245

246246
// Check cache with a request with the same URI path.
247-
$pageCache->getCachedResponse($request, new Response($this->appConfig));
247+
$pageCache->get($request, new Response($this->appConfig));
248248
}
249249
}

0 commit comments

Comments
 (0)