@@ -30,14 +30,14 @@ class Cache implements CacheInterface
3030 *
3131 * @var integer
3232 */
33- private $ cacheLifeTime = 0 ;
33+ private $ cacheLifetime ;
3434
3535 /**
3636 * Life time defined in the expires header
3737 *
3838 * @var integer
3939 */
40- private $ expiresHeaderLifeTime = 0 ;
40+ private $ expiresHeaderLifetime ;
4141
4242 /**
4343 * @var ResponseFactory
@@ -56,13 +56,13 @@ public function __construct(ResponseFactoryInterface $responseFactory)
5656
5757 public function getCachedValueForRequest (RestRequestInterface $ request ): ?ResponseInterface
5858 {
59- $ cacheLifeTime = $ this ->getCacheLifeTime ();
59+ $ cacheLifetime = $ this ->getCacheLifetime ();
6060
6161 /*
6262 * Use caching if the cache life time configuration is not -1, an API
6363 * path is given and the request is a read request
6464 */
65- $ useCaching = ($ cacheLifeTime !== -1 ) && $ request ->getPath ();
65+ $ useCaching = ($ cacheLifetime !== -1 ) && $ request ->getPath ();
6666 if (!$ useCaching ) {
6767 return null ;
6868 }
@@ -85,29 +85,26 @@ public function getCachedValueForRequest(RestRequestInterface $request): ?Respon
8585 return $ response
8686 ->withHeader (Header::CONTENT_TYPE , $ responseData [Header::CONTENT_TYPE ])
8787 ->withHeader (Header::LAST_MODIFIED , $ responseData [Header::LAST_MODIFIED ])
88- ->withHeader (Header::EXPIRES , $ this ->getHttpDate (time () + $ this ->getExpiresHeaderLifeTime ()))
88+ ->withHeader (Header::EXPIRES , $ this ->getHttpDate (time () + $ this ->getExpiresHeaderLifetime ()))
8989 ->withHeader (Header::CUNDD_REST_CACHED , 'true ' );
9090 }
9191
9292 public function setCachedValueForRequest (
9393 RestRequestInterface $ request ,
9494 ResponseInterface $ response ,
9595 ResourceConfiguration $ resourceConfiguration
96- ) {
96+ ): void {
9797 if (false === $ this ->canBeCached ($ request , $ response )) {
9898 return ;
9999 }
100100
101- $ cacheLifeTime = $ resourceConfiguration ->getCacheLifetime ();
102- if ($ cacheLifeTime < 0 ) {
103- $ cacheLifeTime = $ this ->getCacheLifeTime ();
104- }
101+ $ cacheLifetime = $ this ->getCacheLifetime ();
105102
106103 /*
107104 * Use caching if the cache life time configuration is not -1, an API
108105 * path is given and the request is a read request
109106 */
110- $ useCaching = ($ cacheLifeTime !== -1 ) && $ request ->getPath ();
107+ $ useCaching = ($ cacheLifetime !== -1 ) && $ request ->getPath ();
111108 if (!$ useCaching ) {
112109 return ;
113110 }
@@ -123,7 +120,7 @@ public function setCachedValueForRequest(
123120 Header::LAST_MODIFIED => $ this ->getHttpDate (time ()),
124121 ],
125122 $ this ->getTags ($ request ),
126- $ cacheLifeTime
123+ $ cacheLifetime
127124 );
128125 }
129126
@@ -147,12 +144,12 @@ public function getCacheKeyForRequest(RestRequestInterface $request): string
147144 /**
148145 * Sets the cache life time
149146 *
150- * @param int $cacheLifeTime
147+ * @param int $cacheLifetime
151148 * @return $this
152149 */
153- public function setCacheLifeTime (int $ cacheLifeTime ): CacheInterface
150+ public function setCacheLifetime (int $ cacheLifetime ): CacheInterface
154151 {
155- $ this ->cacheLifeTime = $ cacheLifeTime ;
152+ $ this ->cacheLifetime = $ cacheLifetime ;
156153
157154 return $ this ;
158155 }
@@ -162,20 +159,20 @@ public function setCacheLifeTime(int $cacheLifeTime): CacheInterface
162159 *
163160 * @return int
164161 */
165- public function getCacheLifeTime (): int
162+ public function getCacheLifetime (): int
166163 {
167- return $ this ->cacheLifeTime ;
164+ return $ this ->cacheLifetime ;
168165 }
169166
170167 /**
171168 * Sets the life time defined in the expires header
172169 *
173- * @param int $expiresHeaderLifeTime
170+ * @param int $expiresHeaderLifetime
174171 * @return $this
175172 */
176- public function setExpiresHeaderLifeTime (int $ expiresHeaderLifeTime ): CacheInterface
173+ public function setExpiresHeaderLifetime (int $ expiresHeaderLifetime ): CacheInterface
177174 {
178- $ this ->expiresHeaderLifeTime = $ expiresHeaderLifeTime ;
175+ $ this ->expiresHeaderLifetime = $ expiresHeaderLifetime ;
179176
180177 return $ this ;
181178 }
@@ -185,9 +182,20 @@ public function setExpiresHeaderLifeTime(int $expiresHeaderLifeTime): CacheInter
185182 *
186183 * @return int
187184 */
188- public function getExpiresHeaderLifeTime (): int
185+ public function getExpiresHeaderLifetime (): int
186+ {
187+ return $ this ->expiresHeaderLifetime ;
188+ }
189+
190+ /**
191+ * Sets the concrete Cache instance
192+ *
193+ * @param \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend $cacheInstance
194+ * @internal
195+ */
196+ public function setCacheInstance ($ cacheInstance )
189197 {
190- return $ this ->expiresHeaderLifeTime ;
198+ $ this ->cacheInstance = $ cacheInstance ;
191199 }
192200
193201 /**
@@ -217,17 +225,6 @@ private function getCacheInstance()
217225 return $ this ->cacheInstance ;
218226 }
219227
220- /**
221- * Sets the concrete Cache instance
222- *
223- * @param \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend $cacheInstance
224- * @internal
225- */
226- public function setCacheInstance ($ cacheInstance )
227- {
228- $ this ->cacheInstance = $ cacheInstance ;
229- }
230-
231228 /**
232229 * Clears the cache for the current request
233230 *
0 commit comments